mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
+1
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user