compare to NaN is not working

function test()
    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?
I'm not sure why that doesn't work bu try this if statement instead

if (numtype(k)==2)
proland wrote:
I'm not sure why that doesn't work bu try this if statement instead

if (numtype(k)==2)


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.
I'd second reading up on IEEE754, it's quite important to know a lot of stuff in there.

print NaN==Inf
  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