Mon, 17 Jul 2000 17:51:27 +0200 (CEST), Michael Marte
<[EMAIL PROTECTED]> pisze:
> When adding the three double numbers
> 0.7, 0.2, and 0.1, a ghc 4.07-compiled program (compilation flag -O)
> yields 0.9999999999999999. Whatever this string stands for, the number is
> considered to be < 1.0, which breaks my program. What to do?
Use Rational instead of Double.
Or fix the program to not depend on exactness of floating point
computations.
All languages having Double-like floating point type has this problem.
It's not a bug in the language but improper use. Numbers like 0.1
are simply not representable exactly in the binary floating point type.
BTW: the "default default" in Haskell98 is (Integer,Double).
Maybe it should better be (Integer,Rational,Double) instead?
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-