format hex
x = NaN
x =
fff8000000000000
Always use the isnan function to verify that the elements in an array are NaN:
isnan(x)
ans =
1
MATLAB preserves the “Not a Number” status of alternate NaN representations and treats all of the
different representations of NaN equivalently. However, in some special cases (perhaps due to
hardware limitations), MATLAB does not preserve the exact bit pattern of alternate NaN
representations throughout an entire calculation, and instead uses the canonical NaN bit pattern
defined above.
Logical Operations on NaN
Because two NaNs are not equal to each other, logical operations involving NaN always return false,
except for a test for inequality, (NaN ~= NaN):
NaN > NaN
ans =
0
NaN ~= NaN
ans =
1
Infinity and NaN
4-15
Précédent

- 159/1450

Suivant