[Haskell-cafe] Mystery of an Eq instance
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
> Prelude> sqrt 10.0 == 3.1622776601683795
> Prelude> sqrt 10.0 == 3.1622776601683796
> 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
Prelude> 3.1622776601683795 == 3.1622776601683797
Prelude> 3.1622776601683795 == 3.1622776601683798
The truncation happens base 2, not base 10. Is that what's confusing you?
More information about the Haskell-Cafe