Next: , Previous: , Up: layout bitfid immediate   [Contents][Index]


2.2.2.2 Bit patterns of booleans

The representation in machine words uses the 4 least significant bits as tag:

00000000 00000000 00000000 00000110 value=#f C_SCHEME_FALSE
00000000 00000000 00000000 00010110 value=#t C_SCHEME_TRUE

That’s a very large bit space for only two values. However, reserving a special type tag just for booleans simplifies type detection code: we only have to compare the lower four bits with 0110 to check whether an object is a boolean.

The constants C_SCHEME_FALSE and C_SCHEME_TRUE are preprocessor symbols defined at the C language level, in the header file chicken.h.


Next: , Previous: , Up: layout bitfid immediate   [Contents][Index]