Bug in GHC6.10.1?
neil.mitchell.2 at credit-suisse.com
Fri Nov 14 09:43:45 EST 2008
Floating point numbers are just inaccurate, so the results you see aren't too surprisingly.
Interestingly enough, using Hugs, I get the right answer in both cases - so its possible it's a bug, but unlikely.
If you do want exact floating point manipulation then use rational numbers instead, for example:
> 3.0 * 0.2 :: Rational
Which should be read as a fraction, 3/5, which is the right answer.
> -----Original Message-----
> From: glasgow-haskell-users-bounces at haskell.org
> [mailto:glasgow-haskell-users-bounces at haskell.org] On Behalf
> Of José Pedro Correia
> Sent: 14 November 2008 2:33 pm
> To: glasgow-haskell-users at haskell.org
> Subject: Re: Bug in GHC6.10.1?
> I was wondering if there is a bug in GHC 6.10.1 regarding
> number precision.
> As an example, in GHCi with:
> > 3.0 * 0.2
> I get:
> > 2.0 * 0.2
> I have GHC 6.10.1 on Mac OS X 10.5.
> Is this a known bug or should I report it?
> Best regards
> Zé Pedro
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
Please access the attached hyperlink for an important electronic communications disclaimer:
More information about the Glasgow-haskell-users