Type tags in Ruby VALUE
Internally, values in Ruby are 32-bit (at least for 32-bit processors). Some of the least-significant bits are used to store type information. See the VALUE definition in include/ruby/ruby.h. Using type tag bits avoids allocating additional memory for commonly-used immutable values, like integers.
Ruby uses a single-bit tag of 0x01 as the Fixnum type tag. The remaining bits, are used to store the Fixnum’s signed value. This is an immediate value; it doesn’t require storage for the Fixnum value to be allocated, unlike the heap space that would be required for a String. Other types will use different tag bits.
Recent comments
2 days 20 hours ago
4 weeks 5 hours ago
5 weeks 4 days ago
7 weeks 6 days ago
7 weeks 6 days ago
11 weeks 1 day ago
11 weeks 1 day ago
13 weeks 12 hours ago
13 weeks 4 days ago
13 weeks 4 days ago