How can I test if NaN?
Jeffrey Mulligan
jbm at eos.arc.nasa.gov
Tue Apr 4 08:19:50 AEST 1989
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 at 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 ]]
More information about the Comp.sys.sun
mailing list