[ ghc-Bugs-815511 ] Floating pt. arithmetic bugs / inexplicable
inaccuracy
SourceForge.net
noreply at sourceforge.net
Wed Oct 1 05:31:30 EDT 2003
Bugs item #815511, was opened at 2003-09-30 23:48
Message generated for change (Settings changed) made by simonmar
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=815511&group_id=8032
Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Joe Lee (yjo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Floating pt. arithmetic bugs / inexplicable inaccuracy
Initial Comment:
in ghci 6.0.1, eg:
Prelude> 1.1 + 2.2
3.3000000000000003
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2003-10-01 09:12
Message:
Logged In: NO
This is perfectly normal.
Neither 1.1 nor 2.2 can be represented exactly as a Double.
Both of them are represented by numbers that are slightly
too large (all that is promised by Haskell is to represent
them by the closest possible number to the exact number).
When these two (approximations) are added the result happens
not to be the number which is closest approximation of 3.3.
What more can I say? Take an elementary course in numerical
analysis. :)
-- Lennart Augustsson
----------------------------------------------------------------------
Comment By: Simon Marlow (simonmar)
Date: 2003-10-01 08:55
Message:
Logged In: YES
user_id=48280
True, 1.1 2.2 and 3.3 are all representable as doubles, it
seems, so why does 1.1 + 2.2 not give the exact answer?
I get the same result from a C program, so I don't think
this is specific to GHC.
Any experts on floating point arithmetic want to comment on
why this happens?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=815511&group_id=8032
More information about the Glasgow-haskell-bugs
mailing list