compare to NaN is not working
Callisto
function test()
variable k = NaN
if (k== NaN)
print "NaN"
else
print "not NaN"
endif
end
variable k = NaN
if (k== NaN)
print "NaN"
else
print "not NaN"
endif
end
Why does the above result in a "not NaN"? I have to use str2num() and this will return a NaN if it was not successful.
Any ideas?
August 21, 2013 at 10:41 am - Permalink
See also IEEE754 standard.
August 21, 2013 at 11:46 am - Permalink
It's not supposed to work. NaN is actually specified by an IEEE standard for floating point numbers. Other scientific software packages like Matlab and Labview similarly return false for that type of comparison. Your suggestion is the "proper" way to check in Igor.
August 21, 2013 at 11:46 am - Permalink
0
•print NaN==NaN
0
•print Inf==Inf
1
•print Inf==-Inf
0
•print Inf==Inf-1
1
•print 1/0==inf
1
•print 0/0
NaN
August 21, 2013 at 04:59 pm - Permalink