boxing_word.h: lossless float encoding using rotation

Replace lossy 2-bit truncation with rotation-based encoding for
64-bit word boxing with float64. The new scheme uses
rotl64(float_bits - ADDEND, 3) to embed floats inline with full
52-bit mantissa precision. Floats with exponents outside [-255,+256]
(0.0, NaN, Inf, very small/large values) fall back to heap-allocated
RFloat.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-02-18 09:40:13 +09:00
parent 4e63489d1a
commit b6148c893f
3 changed files with 96 additions and 32 deletions
+1 -1
View File
@@ -3959,7 +3959,7 @@ init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
case MRB_TT_ISTRUCT:
mrb_istruct_copy(dest, obj);
break;
#if !defined(MRB_NO_FLOAT) && defined(MRB_WORDBOX_NO_FLOAT_TRUNCATE)
#if !defined(MRB_NO_FLOAT) && defined(MRB_WORD_BOXING)
case MRB_TT_FLOAT:
{
struct RFloat *f = (struct RFloat*)mrb_obj_ptr(dest);