Reputation: 5551
If I recall correctly, floating point numbers allot a certain number of bits to the power, and a certain number of bits to the significant digits. However, I'm having a bit of a hard time making sense of what seems to be the maximum floating point scientific notation number in python3 on my 64-bit linux system:
>>> 1.8e308
inf
>>> 1.7e308
1.7e+308
What is going on here?
To be clear, I am not interested in what the maximum floating point value is. I am interested in the reasoning behind why it is the value that it is. For example, it seems as though the overflow would happen on some even power of two for the significant digits part. Why does this happen somewhere between 1.7 and 1.8? That seems strange.
Upvotes: 1
Views: 1408
Reputation: 222933
“1.7” and “1.8” are not digits from the fraction portion of the floating-point representation. They are decimal digits resulting from expressing the number in decimal, not binary floating-point.
The overflow occurs at a power of two, 21024, which is about 1.797693•10308.
Upvotes: 4
Reputation: 67
To get the exact max value, try doing:
import sys
sys.float_info.max
You would get: 1.7976931348623157e+308
Upvotes: -1