bit shifting

Eliot & Linda elcm at pacbell.net
Thu Apr 23 16:29:41 UTC 1998


Dan Ingalls wrote:
[snip]

> So, if we were to reveal a specific bit representation for the purpose of allowing logic on negative numbers, can anyone explain why it should be two's complement?

In no particular order, and with no claim to rationality or
usefulness....

2's complement allows finite representation of the useful value of an
infinite string of set bits.

2's complement is more aesthetically pleasing.  sign-magnitude, with its
two zeros fells clumsy.  2's complement is "good engineering", like the
arch.  It has an elegant simplicity.  Like much in pysics it is
non-obvious, but once understood, consistent and powerful (in fact
complement representations in general are; in fact, if we were taught to
do subtraction by complement addition we'd probably all be faster
subtractors).

Most expressions of bit-manipulation algorithms from cryptography, etc,
are in two's complement.  Transliterating from these into Squeak would
be made more difficult if representations had to be changed.

Gartuitous incompatibilities with other Smalltalks hurt all
SMalltalkers, Squeakers included.

If it ain't broke, don't fix it.
_______________,,,^..^,,,_______________
Eliot





More information about the Squeak-dev mailing list