Bit Manipulation Question
colin.sarsfield at usa.net
Wed Dec 9 00:16:36 UTC 1998
"R. A. Harmon" wrote:
> I noticed to following results while testing Squeak bit manipulation. I
> think the result of evaluating the second snippet of code is in error. If
> it isn't, I would appreciate it if anyone could straighten me out.
> (-10 "-2r1010"
> bitOr: 2r1000) radix: 2.
> "-> '-2r10'" Error?
This isn't an error. -2r1010 is actually stored as
2r11111111111111111111111111110110 (assuming 32-bit words). This is
refered to as 2's complement integer storage. Basically the high bit
means it's negative and then you perform a bitwise not on the whole
thing and add 1 to get what the number is.
More information about the Squeak-dev