bit shifting
Eliot & Linda
elcm at pacbell.net
Tue Apr 14 04:04:52 UTC 1998
Dan Ingalls wrote:
>
> Comments?
IMNHO both the original poster and the ANSI standard are wrong :) As
Ken Dickey pointed-out a 2's complement representation with infinite
precision (infinitely many bits "to the left") is perfectly consistent.
CLOS got it right. In this representation -1 bitShift: 1 *is* -2. -1
bitAt: n should be 1 for all n (even if in VisualWorks it creates an
integer this large to test, and hence -1 bitAt: SmallInteger maxVal
takes rather a long time to compute :) :)
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". Anyone assuming that
-1 bitShift: 1 should be (2 raisedTo: 32) - 2 should be using C and
avoiding i286s and Alphas at all costs...
_______________,,,^..^,,,_______________
Eliot
More information about the Squeak-dev
mailing list
|