2013/4/25 David MacMahon <davidm / astro.berkeley.edu>
>
> Nice work tracking this down!
>
> I don't understand how it fixes the compiler specific aspect of the
> problem you found where gcc 4.5.2 on MinGW had the problem but gcc 4.7.2 on
> MinGW did not.  Does gcc 4.7.2 on MinGW already automatically do whatever
> "_control87(_PC_53, _MCW_PC)" does, but gcc 4,5,2 on MinGW does not
> automatically do it so it needs to be done explicitly?
>
The console application built with mingw32 compiler  calls _fpreset
funciton at startup.
The _fpreset function is defined in MSVCRT.dll which set FP default
precision to 53 bit mantissa.

But in mingwrt-3.18 library which bundled in mingw32 4.7.2 redefined
_fpreset function to change FP default precision from 53 to 64-bit
mantissa.
Actually, the "_control87(_PC_53, _MCW_PC)" means lowering precision
from 64 to 53-bit mantissa.

BTW, why we should consider  FP precision?
When converting string value to double value, ruby calls ruby_strtod
function instead of native strtod function.
The ruby_strtod function is based on David M. Gay's netlib library
which requires double-precision (53-bit) rounding precision.

> Is the __MINGW32__ macro enough of a check?  I wonder if it could enable
> the _control87 call on system where it is not present.
>
Ruby 1.9.x requires Windows 2000 or later OS which requires Pentium CPU.
And most x86 processors since the Intel 80486 have had x87
instructions implemented in the main CPU.
I cannot imagine a system with Windows 2000 and not present x87 instructions.


Regards,
Park Heesob