result = IsNan(x)
x
is a special NaN value (not-a-number). NaN is a special
return value for undefined floating point numbers such as the result
of 0/0 or the square root of negative numbers.
Note that you should not test for NaN by comparing a number with itself,
expecting to get False
. This won't work on all platforms. Using IsNan()
is the only portable way to check if a value is NaN.
The value of NaN is also in a predefined constant named #NAN
but due to
the design of Hollywood's parser you may only access this value using
the GetConstant() function. Using it literally in
a script, i.e. outside a string, will fail.
True
if x
is a NaN value, False
otherwisea=RawDiv(0,0) Print(IsNan(a))This will print "1" to the screen because the result of 0/0 is NaN. Note that we need to use RawDiv() here because the division operator as well as Div() will not allow a division by zero.