Ticket #7069 (closed bug: wontfix)
precision/rounding bug with floating point numbers on 32-bit-platforms
|Reported by:||shahn||Owned by:||simonmar|
|Keywords:||Float Double 32 precision rounding||Cc:||alexey.skladnoy@…|
|Type of failure:||Incorrect result at runtime||Difficulty:||Unknown|
|Test Case:||Blocked By:|
Comparing floating point numbers (Floats or Doubles, using (==)) that are constructed by equal terms sometimes evaluates to False. A term that produces normal floating point values (as opposed to NaN or Infinity) should always be equal to itself. This bug effectively breaks referential transparency.
This bug occurs with ghc-7.4.2 when compiling with "-O2" on 32-bit linux ubuntu-11.10. (I guess, it happens on all 32-bit platforms.)
The attached file demonstrates the bug.
Simon Marlow expressed his doubts, this bug will be fixed. See also: http://www.haskell.org/pipermail/glasgow-haskell-users/2012-July/thread.html#22565
- compile with "-msse2" if available
- use approximate equivalence