Type tags in MRI Ruby VALUE
Internally, values in MRI 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
25 weeks 7 hours ago
35 weeks 1 day ago
1 year 1 week ago
1 year 17 weeks ago
1 year 51 weeks ago
2 years 11 weeks ago
2 years 14 weeks ago
2 years 14 weeks ago
2 years 14 weeks ago
2 years 14 weeks ago