On Saturday 19 July 2003 05:42 pm, Aeloria Resa wrote:
> It's casting 0xFF, not 0x80, but anyways. Umm, why'd you replace it with
> 1s? When it get's cast, I was under the impression that, like everything
> else, it pads it with 0s.
>
> 0.o?
>
> I'm still rather confused.
Bytes are signed. The byte 0x80 (10000000) is -128. Cast to an integer (also 
signed), it must remain -128, or 11111111 11111111 11111111 10000000. To get 
this back down to the original byte, it must be ANDed with 0xFF to only get 
the last byte. The 0xFF is an integer constant, not a byte constant, and as 
such equals 00000000 00000000 00000000 11111111.

And a pox upon Sun for (among other things) not having any fixed-size unsigned 
types.
-- 
"I love deadlines. I love the whooshing sound they make as they go by."
        - Douglas Adams
Nick Tarleton - [EMAIL PROTECTED] - PGP key available

_______________________________________________
devl mailing list
[EMAIL PROTECTED]
http://hawk.freenetproject.org:8080/cgi-bin/mailman/listinfo/devl

Reply via email to