Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is realmin > eps(0)?

realmin "returns the smallest positive normalized floating point number in IEEE double precision". eps(X) "is the positive distance from ABS(X) to the next larger in mangitude floating point number of the same precision as X".

If I am interpreting the above documentation correctly, then realmin -- the smallest positive number that can be represented -- must be smaller than eps (0). But:

>> realmin; % 2.2251e-308
>> eps(0);  % 4.9407e-324

Obviously, eps(0), which is even smaller, can be represented too. Could someone explain this to me?

like image 548
Andreas Avatar asked Apr 04 '13 08:04

Andreas


People also ask

What is Realmin?

f = realmin returns the smallest positive normalized floating-point number in IEEE® double precision. This is equal to 2^(-1022) . example. f = realmin( precision ) returns the smallest positive normalized floating-point number in IEEE single or double precision.

What does EPS mean in MATLAB?

Description. eps returns the distance from 1.0 to the next largest floating-point number. The value eps is a default tolerance for pinv and rank , as well as several other MATLAB functions. On machines with IEEE floating-point arithmetic, eps = 2^(-52) , which is roughly 2.22e-16 . See Also.

What is the smallest number MATLAB can handle?

Convert Value Smaller Than intmin Return the smallest value of the 8-bit signed integer type, which is –128.

What is the smallest positive number that can be assigned by MATLAB using the cloud?

REALMIN('single') is the smallest positive normalized single precision floating point number on your computer. realmin is 2^(-1022) or about 2.2251e-308 .


2 Answers

This is a floating point issue. You should go read up on denormal numbers.

Briefly, realmin returns the smallest positive normalized floating point number. But it's possible to have denormal numbers that are smaller than this and still representable in floating point, which is what eps(0) returns.

Quick explanation of denormal numbers

A binary floating point number looks like this:

1.abcdef * 2^M

where abcdefg are each either 0 or 1, and M is a number in the range -1022 <= M <= 1023. These are called normalized floating point numbers. The smallest possible normalized floating point number is 1 * 2^(-1022).

The denormal numbers looks like this

0.abcdef * 2^(-1022)

so they can take values that are smaller than the smallest possible normalized floating point number. The denormal numbers linearly interpolate between -realmin and realmin.

like image 59
Chris Taylor Avatar answered Oct 15 '22 22:10

Chris Taylor


Perhaps it is a matter of definition, this is what I see in the documentation of eps:

For all X of class double such that abs(X) <= realmin, eps(X) = 2^(-1074)
like image 41
Dennis Jaheruddin Avatar answered Oct 15 '22 20:10

Dennis Jaheruddin