[Haskell-cafe] instance Enum Double considered not entirely great?
Ketil Malde
ketil at malde.org
Wed Sep 21 09:43:24 CEST 2011
Daniel Fischer <daniel.is.fischer at googlemail.com> writes:
>>> 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
More information about the Haskell-Cafe
mailing list