[Haskell-cafe] Mystery of an Eq instance
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Sep 20 18:31:20 CEST 2013
On Fri, Sep 20, 2013 at 09:47:24PM +0530, damodar kulkarni wrote:
> Ok, let's say it is the effect of truncation. But then how do you explain
> this?
>
> Prelude> sqrt 10.0 == 3.1622776601683795
> True
> Prelude> sqrt 10.0 == 3.1622776601683796
> True
>
> Here, the last digit **within the same precision range** in the fractional
> part is different in the two cases (5 in the first case and 6 in the second
> case) and still I am getting **True** in both cases.
What do you mean the "same precision range"? Notice:
Prelude> 3.1622776601683795 == 3.1622776601683796
True
Prelude> 3.1622776601683795 == 3.1622776601683797
True
Prelude> 3.1622776601683795 == 3.1622776601683798
False
The truncation happens base 2, not base 10. Is that what's confusing you?
Tom
More information about the Haskell-Cafe
mailing list