The issue is that when you create the following array:
[(realmax('double')-10) realmin('double') realmax('single')]
%// Inf 0 3.402823e+38
The first entry is infinity and by definition, eps(Inf) == NaN
.
Why does this happen, well realmax('single')
returns a single-precision number and realmax('double')
returns a double precision number.
REALMAX('single')
returns the largest finite floating point number in
IEEE single precision.
When you concatenate the two, MATLAB downcasts the entire array to a single
precision number which obviously causes the realmax('double')-10
to excede the range of the datatype and it becomes infinity.
class(realmax('double'))
%// double
class(realmax('single'))
%// single
class([(realmax('double')-10) realmin('double') realmax('single')])
%// single
When you call eps(realmax('double') - 10)
by itself, the very large double
is actually a double
and eps
returns the expected epsilon.