bit shifting

Wim Boot wimb at bart.nl
Tue Apr 14 18:21:52 UTC 1998


Ian Piumarta wrote:

>It's a well-known fact the there are two flavours of right shift,
>arithmetic and logical [1].

That's purely an implementation artifact resulting from limited
size integers. I totally agree with Eliot:

>IMNHO both the original poster and the ANSI standard are wrong :) 
>Bit manipulation should be consistent with all negative numbers having
>an infinite number of ones "to the left" and all non-negative integers
>having an infinite number of zeros "to the left".

BTW, Hans-Martin complained about a _left_ shift:

>	(-1 bitShift: 1) = -2

I wouldn't expect any other result, so I think there must have been a
typo somewhere.

Wim Boot





More information about the Squeak-dev mailing list