[comp.sys.sun] How can I test if NaN?

jbm@eos.arc.nasa.gov (Jeffrey Mulligan) (04/04/89)

Is there a way to test if a floating point variable is "NaN" or == "Inf" ?

I suppose that I could always cast to integer, strip the exponent and test
if the mantissa is in the legal range, but I am hoping for something more
machine independent.

(in case you're wondering why I care, we have an array processor which
thoughtfully gives NaN for atan2(0,0).  Granted, this quantity is
undefined, but a legitimate value (like 0) wouldn't wreak havoc with
normalization!  I begin normalizing by finding the min and max; I'd like
to be able to test if the min and max are NaN's!)

	Jeff Mulligan (jbm@aurora.arc.nasa.gov)
	NASA/Ames Research Ctr., Mail Stop 239-3, Moffet Field CA, 94035
	(415) 694-6290

[[ I hate to say "RTFM", but....  Please see ieee_functions(3M).  You will
find the functions "isinf" and "isnan" documented there.  --wnl ]]