bit shifting

Allen Wirfs-Brock Allen_Wirfs-Brock at Instantiations.com
Tue Apr 14 00:07:25 UTC 1998


At 01:25 PM 4/13/98 -0600, Dan Ingalls wrote:
....
>THEREFORE I would propose simply to forbid all bit manipulation on
negative numbers, and fix the problems that crop up.  This is the only way
I see to avoid the problem of how negative numbers are represented in
Squeak (which happens to be different for small and large integers!).
Besides LI division, there may be a couple of places in the
InterpreterSimulator where we are manipulating 32-bit words, but I would be
willing to fix these, too.
>
>Use positive numbers for bit patterns.
>Use divide to divide numbers, and bitShift to manipulate bit patterns.
>
>Comments?
>
>	- Dan

Note that for similar reasons ANSI Smalltalk specified the results of bit
operations involving negative integers as being "undefined" and does not
specify a "not" operation. Not (to a specific bit precisions can be
accomplished using #bitXor:). It also defines some additional bit field
related operations that may be of interest.

In general, arbitrary length bit field operation and 2's complement
arithmetic don't mix well.

Allen_Wirfs-Brock at Instantiations.com





More information about the Squeak-dev mailing list