[Vm-dev] positive32BitValueOf: fail with LargePositiveInteger

David T. Lewis lewis at mail.msen.com
Fri Oct 8 21:47:28 UTC 2010


On Fri, Oct 08, 2010 at 07:12:13PM +0200, Mariano Martinez Peck wrote:
> 
> So....I don't understand...how can I have a LargePositiveInteger but that is
> less than 32 bits?  Wouldn't that  be a SmallInteger?

SmallInteger maxVal hex ==> '16r3FFFFFFF'.

The largest positive two-compliment integer that fits into 32 bits is
16rEFFFFFFF, so any Integer in the range 16r4000000 through 16rEFFFFFFF
is a LargePositiveInteger that can fit into a signed 32-bit C int.

Thus the number of LargePositiveInteger values that fit into a 32-bit
twos-compliment representation is (16r4000000 to: 16rEFFFFFFF) size ==> 3959422976

Note that a SmallInteger is represented internally as a 31-bit value,
which accounts for the difference. It's a bit confusing when you are used
to thinking of 32-bit int values.

Dave



More information about the Vm-dev mailing list