From: Tim Pease Date: 2007-04-14T02:36:16+09:00 Subject: Re: Question about Fixnum On 4/13/07, huang zhimin wrote: > Why the range of Fixnum is -2^30 ~ 2^30 rather than -2^31 ~2^31 ? > > -- > flyerhzm@hotmail.com > Fixnum objects are immediate objects in the Ruy source code (other immediate objects are nil, true, false, and symbols). These immediate objects occupy 4 bytes of storage (unsigned long) on most machines. They are accessed by casting and bit shifting in the Ruby source code. The other core types (String, Hash, Array, Object, Class, etc.) are structures and are accessed by pointer dereference. The sneaky part is that all these objects are referenced as VALUE types in the source code. The allocated structures are 4-byte aligned such that the bottom two bits will always be zero. If bit zero is set to 1, then you have a Fixnum. The consequence is that you have to right shift your Fixnum VALUE to get an integer, and hence, you loose one bit of precision for Fixnum. Read more here ... . Scroll down to the secion on "Small Integers". Blessings, TwP