
21 Sep
2011
21 Sep
'11
3:43 a.m.
Daniel Fischer
Btw, -0.0 can be problematic too.
How so? As far as I can tell Ord and Eq treat it as equal to 0.0 in every way,
Yes. Which can be inconvenient if you are interested in whether you got a -0.0, so if that's the case, you can't simply use (== -0.0).
For instance, somebody might have the idea to store floating point values in a HashSet, which might (or might not) produce a different result from the regular Set in this case. Conversely, you might get different values out of the set than the ones you put into it, which could be surprising. IMO, it's definitely a good practice to avoid otherwise distinguishable values comparing as equal. -k -- If I haven't seen further, it is by standing in the footprints of giants