As we said above, immediate values are not pointers:
Fixnum
,
Symbol
,
true
,
false
, and
nil
are stored directly in
VALUE
.
Fixnum
values are stored as 31-bit numbers
[Or 63-bit on
wider CPU architectures.] that are formed by shifting the original
number left 1 bit and then setting the least significant bit (bit
0) to ``1.'' When
VALUE
is used as a pointer to a specific Ruby
structure, it is guaranteed always to have an LSB of zero; the
other immediate values also have LSBs of zero. Thus, a simple
bit test can tell you whether or not you have a
Fixnum
.
There are several useful conversion macros for numbers as well as
other standard datatypes shown in Table 17.1 on page 174.
The other immediate values (
true
,
false
, and
nil
) are
represented in C as the constants
Qtrue
,
Qfalse
, and
Qnil
, respectively. You can test
VALUE
variables against
these constants directly, or use the conversion macros (which perform
the proper casting).