[BUG] Totally wrong comment in SmallInteger class description

David N. Smith (IBM) dnsmith at watson.ibm.com
Mon Jul 2 19:16:43 UTC 2001


All:

The class comment in SmallInteger states:

	My instances are 30-bit numbers, stored in twos complement form. The allowable 
	range is approximately +- 1 billion (see SmallInteger minVal, maxVal).

which is wrong. The virtual machine uses a one bit tag to indicate that the rest of the 32 bit object pointer is a SmallInteger which means that the instances of SmallInteger are 31-bits in length. One can also write code to check this maximum; it also indicates a 31-bit length for SmallIntegers.

It is not valid to think of the 'sign bit' as the other bit for several reasons:

* If we did that then we'd speak of 31-bit arithmetic on the native hardware; we don't. It's 32-bit arithmetic.

* The 31 bits of a SmallInteger are in twos complement form which has no sign bit. (The left bit is always on when the number is negative, but that is an artifact of twos complement.)

The comment should be fixed.

(This is another contribution for most trivial bug fix.)

Dave





More information about the Squeak-dev mailing list