3 ms·
In 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..
by SonOfLilit 2y ago
In 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;
}
}