MATLAB Smallest Integer in floating point number system
显示 更早的评论
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.
采纳的回答
更多回答(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 个评论
Hmm!
2021-1-26
Rik
2021-1-26
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
2021-1-26
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!
2021-1-27
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
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!