From: Heesob Park Date: 2013-04-25T11:09:11+09:00 Subject: [ruby-core:54561] Re: [ruby-trunk - Bug #8299] Minor error in float parsing 2013/4/25 naruse (Yui NARUSE) : > > Issue #8299 has been updated by naruse (Yui NARUSE). > > > phasis68 (Heesob Park) wrote: >> I found the issue is due to the difference of the floating point precision. >> >> Here is a patch for this issue: >> >> diff --git a/numeric.c b/numeric.c.new >> index 97ba104..c548c0f 100644 >> --- a/numeric.c >> +++ b/numeric.c.new >> @@ -3767,6 +3767,9 @@ Init_Numeric(void) >> _control87(MCW_EM, MCW_EM); >> _control87(_control87(0,0),0x1FFF); >> #endif >> +#if defined(__MINGW32__) >> + _control87(_PC_53, _MCW_PC); >> +#endif >> id_coerce = rb_intern("coerce"); >> id_to_i = rb_intern("to_i"); >> id_eq = rb_intern("=="); > > It specify fraction as 53 bit (other IEEE 754 FPU's 52 bit with economized form), but its internal exponent is still 15 bit. > For example following result should be still different (I don't tested on mingw32). > > [0x0008008000000000,0x3ff0000000000001].pack("Q2").unpack("d2").inject(&:*) > > Therefore use SSE2 rather than such workaround. I'm not sure why you think SSE2 can fix this issue. The ruby_strtod function used in converting string value to double value requires double-precision (53-bit) rounding precision but mingw32 gcc 4.5.2 have default 64-bit precision which higher than other compilers. So the patch lowers precision from 64 bit to 53 bit. Regards, Park Heesob