[comp.lang.c] Floating point exceptions

kdq@demott.COM (Kevin D. Quitt) (08/04/90)

    I need to be able to examine an IEEE double to see if it is anything
but a number (e.g. NAN) *before* I actually try to use it.  I know this
isn't really the right group (although it will be in c 8-), but I'm not
sure where to take it.

    Any pointers to the IEEE spec on-line or via mail would be
appreciated.  E-mail is preferred, I'll summarize iff there's a lot of
interest.  Thanks.




-- 
 _
Kevin D. Quitt         demott!kdq   kdq@demott.com
DeMott Electronics Co. 14707 Keswick St.   Van Nuys, CA 91405-1266
VOICE (818) 988-4975   FAX (818) 997-1190  MODEM (818) 997-4496 PEP last

                96.37% of all statistics are made up.

ark@alice.UUCP (Andrew Koenig) (08/04/90)

In article <446@demott.COM>, kdq@demott.COM (Kevin D. Quitt) writes:

>     I need to be able to examine an IEEE double to see if it is anything
> but a number (e.g. NAN) *before* I actually try to use it.

If your implementation is nice to you, you will have some library
function like isNaN().

If not, then you're supposed to be able to turn traps off and
(I think) check whether the number is equal to itself (!) --
I believe that all six relational operators are supposed to
return `false' if either operand is a NaN.  If you have a
signalling NaN, though, you'd better make sure you turn traps
off.
-- 
				--Andrew Koenig
				  ark@europa.att.com