MATLAB Smallest Integer in floating point number system
Show older comments
I am interested in finding the smallest integer in MATLAB, say y, that is not representable in 64 bit floating point format so that the floating point number is not equal to y i.e., fl(y) is not y.
My insticts tells me that could be the underflow level given as 2^-1022 and its corresponding floating point number is 1.00...2^{-1022}
I don't whether this is correct. Help me find the number please.
Accepted Answer
More Answers (1)
You are indeed correct:
realmin,log2(realmin)
Unless you actually mean integer, in which case the smallest integer is 0.
If you mean the lowest number of an IEEE double: that would be
-realmax
8 Comments
Hmm!
on 26 Jan 2021
Rik
on 26 Jan 2021
Do you mean what the binary representation would be?
If it isn't representable that means you can't write it.
This is the binary for the smallest number you can write with a double:
b=dec2bin(typecast(realmin,'uint64'),64);
fprintf('S E F\n%s %s %s\n',b(1),b(2:12),b(13:end))
If you want anything smaller you will need to use a quad or vpa. Anything between 0 and realmin can't be written as a double.
Rik
on 26 Jan 2021
Yes. I typecast it to a 64 bit integer and converted that to a 64 digit binary number. I added two spaces and a header to explain what the numbers are.
Hmm!
on 27 Jan 2021
Anything between 0 and realmin can't be written as a double.
Incorrect. realmin is the smallest normalized positive value, but there are smaller subnormal positive values.
x = realmin
y = eps(0)
y < x
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!