If you can't stomach the weirdness of floating point then perhaps you should try to define your own type that obeys all the expected laws? :)<br><br><div class="gmail_quote">On Jan 11, 2008 3:36 AM, Wolfgang Jeltsch <
<a href="mailto:g9ks157k@acme.softbase.org">g9ks157k@acme.softbase.org</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Am Freitag, 11. Januar 2008 11:03 schrieb Felipe Lessa:
<br><div class="Ih2E3d">> Another thing for the record: Goldberg says<br>><br>> "The introduction of NaNs can be confusing, because a NaN is never<br>> equal to any other number (including another NaN), so x = x is no
<br>> longer always true. In fact, the expression x /= x is the simplest way<br>> to test for a NaN if the IEEE recommended function Isnan is not<br>> provided. Furthermore, NaNs are unordered with respect to all other
<br>> numbers, so x <= y cannot be defined as not x > y. Since the<br>> introduction of NaNs causes floating-point numbers to become partially<br>> ordered, a compare function that returns one of <, =, >, or unordered
<br>> can make it easier for the programmer to deal with comparisons."<br>><br>> Goldberg, David. What Every Computer Scientist Should Know About<br>> Floating-Point Arithmetic.<br>> <a href="http://docs.sun.com/source/806-3568/ncg_goldberg.html" target="_blank">
http://docs.sun.com/source/806-3568/ncg_goldberg.html</a> .<br>><br>> As GNU is not Unix, NaN is not a number, so what is standard about<br>> numbers doesn't work for them. I don't think there's a compeling
<br>> reason about changing this behavior, specially because it's what's<br>> specified in the IEEE 754.<br><br></div>There is a really compelling reason: If the order on floating point numbers is<br>partial then there is no meaningful Ord instance for them.
<br><br>And what do Hugs and GHCi say? Their answers are plain horror:<br><br> Hugs, version 20050308:<br><br> compare (0 / 0) (0 / 0) => EQ<br><br> 0 / 0 == 0 / 0 => False<br><br> GHCi 6.8.2:<br>
<br> compare (0 / 0) (0 / 0) => GT<br><br> 0 / 0 > 0 / 0 => False<br><br>Anyone interested in filing bug reports?<br><br>> […]<br><br>Best wishes,<br><font color="#888888">Wolfgang<br></font><div>
<div></div><div class="Wj3C7c">_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">
http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></div></div></blockquote></div><br>