IIRC, the main Ruby implementation, saves Fixnums as immediate values, using some of the least significant bits of a word to mark it as Fixnum instead of a pointer to an object on the heap. Therefore, on a 32-bit machine, Fixnums are only 29 bits (or whatever) instead of a complete word.
Therefore, because of this, you cannot add methods to a single "instance" of Fixnum, and you cannot subclass it.
If you are set to a โFixnum-like class,โ you may have to create a class with a Fixnum instance variable and redirect the method calls accordingly.
Jason creighton
source share