NaN

ark at alice.UUCP ark at alice.UUCP
Mon Jun 13 00:05:26 AEST 1988


In article <660011 at hpclscu.HP.COM>, shankar at hpclscu.UUCP writes:
 
> Thus, it's kind of difficult to do a thing like:

>    if (f == NaN) { /* .. */ }

Not if traps are disabled.  NaN is not equal to anything, so you
can simply say

	if (f != f) { /* ... */ }

> How's about
 
>    #define NaN (1.0 / 0.0)
 
Nope.  1.0/0.0 is infinity, not NaN.  However, if appropriate traps
are disabled, 0.0/0.0 is a NaN.

> A good solution would be to add a few routines to libm.a

IEEE recommends specific routines, though I've forgotten what they are.
Of course, any such routines will only work on machines with IEEE
floating point (or equivalent).



More information about the Comp.lang.c mailing list