On Thu, 5 May 2011, Kristoffer Ek wrote:
>
> On 4.5.2011, at 6:20, Erik Petrich wrote:
>
>> long_counter = (char_counter[0] | (char_counter[1] << 8)) |
>> ((unsigned long)(char_counter[2] | (char_counter[3] << 8)) << 16);
>
>
> This overflows at 32767 :-/
>
> -- stoffer
Sorry, I didn't take into account there would be a sign extension in the
first half. Try this instead:
long_counter = (unsigned int)(char_counter[0] | (char_counter[1] << 8)) |
((unsigned long)(char_counter[2] | (char_counter[3] << 8)) << 16);
Erik
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user