[GHC] #3033: numerical error introduced by -O1
GHC
trac at galois.com
Tue Feb 17 04:18:04 EST 2009
#3033: numerical error introduced by -O1
------------------------------+---------------------------------------------
Reporter: roland | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.10.1
Severity: normal | Resolution:
Keywords: | Testcase:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
------------------------------+---------------------------------------------
Comment (by guest):
So, interestingly gcc prints non-zero with no optimization and 0 with
optimization.
The problem is due to the fact the floating point on the 387 compatible
FPU stores a double in 64 bits, but internally computes with 80 bits. So
the first (f x) is computed and stored, then the second one is computed,
and the first one is subtracted. But one of the (f x) calls has 80 bits
all the way and the other has been truncated to 64 bits and lost some
bits.
This is life with the x86, unless you really want to cripple performance
and truncate after each FP operation.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3033#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list