[Mingw-msys] [mingw - MSYS] RE: bash empty for-loop
- Date: Fri, 07 Sep 2007 17:27:00 -0700
- From: Brian Dessent <brian@xxxxxxxxxxx>
- Subject: Re: [Mingw-msys] pow(5,2)=24 ?????!!!!!
[ Why is this on the MSYS mailing list? This has nothing to do with
MSYS. ]
Michael Chen wrote:
> If I compile using GCC, I got wrong answer pow(5,2)=24, but if I use
> Lcc-win32, I got correct one. Can anybody explain? Is there a GCC
> switch which can alter the behavior? What are your commonly used GCC
> switches?
It's not a wrong answer per se. It's that the floating point value was
actually 24.99999999999999999 and you truncated it instead of rounding.
Note that 64 bit IEEE 754 doubles only guarantee accuracy to 15 decimal
places so this is a perfectly legitimate double representation of the
value 25. It's also likely to happen due to the old i387 excess
precision "feature" where all 387 computations are done with 80 bits
precision even if they represent 32 or 64 bit types. See gcc PR 323 for
an extensive treatment of this non-bug. If -ffloat-store fixes the
problem then it's definitely excess precision, which again is not a bug
but a common misunderstanding of how floating point hardware operates.
Brian
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mingw-msys mailing list
Mingw-msys@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/mingw-msys