Section: Base Constants
y = nan
The returned type is a 64-bit float, but demotion to 32 bits preserves the not-a-number. The not-a-number constant has one simple property. In particular, any arithmetic operation with a NaN
results in a NaN
. These calculations run significantly slower than calculations involving finite quantities! Make sure that you use NaN
s in extreme circumstances only. Note that NaN
is not preserved under type conversion to integer types (see the examples below).
--> nan*0 ans = <double> - size: [1 1] nan --> nan-nan ans = <double> - size: [1 1] nan
Note that NaN
s are preserved under type conversion to floating point types (i.e., float
, double
, complex
and dcomplex
types), but not integer types.
--> uint32(nan) ans = <uint32> - size: [1 1] 0 --> complex(nan) ans = <complex> - size: [1 1] nan+ 0 i