4 ms·
Just correction: CRuby uses “Float Self-Tagging” for years.
by funny_falcon 2y ago
Just correction: CRuby uses “Float Self-Tagging” for years.
- refulgentis 2y agoThis is your 4th comment claiming this: it's not true. You're right that Ruby uses tags, ex. Objective-C does also and has for a while. The innovation here is its a tag without the tag bits. That's why its self-tagging, not tagging.
- SonOfLilit 2y agoIn another comment, this user links a CRuby commit that they claim adds it. It seems legit. Linked commit contains code for rotating tagged floats so bits 60..62 go to the least significant positions, and a comment about a range of unboxed floats between 1.7...e-77 and 1.7...e77, plus special casing 0.0 e.g. this excerpt: #if USE_FLONUM #define RUBY_BIT_ROTL(v, n) (((v) << (n)) | ((v) >> ((sizeof(v) * 8) - n))) #define RUBY_BIT_ROTR(v, n) (((v) >> (n)) | ((v) << ((sizeof(v) * 8) - n))) static inline double rb_float_value(VALUE v) { if (FLONUM_P(v)) { if (v == (VALUE)0x8000000000000002) { return 0.0; } else { union { double d; VALUE v; } t; VALUE b63 = (v >> 63); /* e: xx1... -> 011... */ /* xx0... -> 100... */ /* ^b63 */ t.v = RUBY_BIT_ROTR(((b63 ^ 1) << 1) | b63 | (v & ~0x03), 3); return t.d; } } else { return ((struct RFloat *)v)->float_value; } }