Path: utzoo!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!rutgers!bellcore!faline!thumper!ulysses!andante!alice!ark
From: ark@alice.UUCP
Newsgroups: comp.lang.c
Subject: Re: NaN
Message-ID: <7973@alice.UUCP>
Date: 12 Jun 88 14:05:26 GMT
References: <622@phaedra.lamont.Columbia.edu> <660011@hpclscu.HP.COM>
Organization: AT&T Bell Laboratories, Liberty Corner NJ
Lines: 23

In article <660011@hpclscu.HP.COM>, shankar@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).