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.
So the truncation rules seem to be elusive, to __me__.
And also observe the following:
Prelude> (sqrt 10.0) * (sqrt 10.0) == 10.0
False
Prelude> (sqrt 10.0) * (sqrt 10.0) == 10.000000000000002
True
Prelude> (sqrt 10.0) * (sqrt 10.0) == 10.000000000000003
False
Prelude> (sqrt 10.0) * (sqrt 10.0) == 10.000000000000001
True
Prelude>
Ok, again something like truncation or rounding seems at work but the precision rules the GHC is using seem to be elusive, to me.
But more importantly, if one is advised NOT to test equality of two floating point values, what is the point in defining an Eq instance?
So I am still confused as to how can one make a *meaningful sense* of the Eq instance?