
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
so "storing" the value does not work...
Not sure what you mean here. In IEEE floating point, NaN is not equal to anything, especially not to itself. So the above worked, didn't it? And therefore, isNaN :: Double -> Bool isNaN x = not (x == x) but this is wrong (I believe): isNaN' :: Double -> Bool isNaN' x = x /= x Anyway, isNaN is alerady in the Prelude, and so are isInfinite, isDenormalized and isNegativeZero. This is all a bit ill-defined, but you'll have to live with that. If you also want a personal advise: switch on signaling NaNs (there's a C function to do that, simply foreign import it) and have your program bomb out as soon as a NaN is formed. Propagating them through calculations just increases the headache. Udo. -- FORTUNE PROVIDES QUESTIONS FOR THE GREAT ANSWERS: #4 A: Go west, young man, go west! Q: What do wabbits do when they get tiwed of wunning awound?