Hi,

Tamas K Papp wrote:
> Is there a way to use NaN and Infinity as literals, or at least to
> test if a value is NaN or Infinity?

> *Main> let nan=0/0
> *Main> nan
> NaN
> *Main> nan==0/0
> False

This is correct according to the IEEE 754 standard, which defines
that NaN compares unequal to everything, including itself.

You can test the numbers using the isNaN and isInfinite functions.

Incidentally, one can define

  isNaN x = x /= x

for IEEE floating point numbers. Comparing with +Infinity and
-Infinity works as expected.

regards,

Bertram.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to