简体   繁体   English

最大的科学计数法?

[英]Maximum scientific notation?

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: 但是,我很难理解我的64位linux系统上python3中似乎是最大浮点科学计数形式的数字:

>>> 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. 例如,对于有效数字部分,似乎溢出将发生在2的偶数次幂上。 Why does this happen somewhere between 1.7 and 1.8? 为什么会在1.7和1.8之间发生这种情况? That seems strange. 好像很奇怪

“1.7” and “1.8” are not digits from the fraction portion of the floating-point representation. “ 1.7”和“ 1.8”不是浮点表示形式的小数部分后的数字。 They are decimal digits resulting from expressing the number in decimal, not binary floating-point. 它们是十进制数字,是用十进制而不是二进制浮点数表示的。

The overflow occurs at a power of two, 2 1024 , which is about 1.797693•10 308 . 溢出发生在2的幂2 1024处 ,约为1.797693•10 308

To get the exact max value, try doing: 要获得确切的最大值,请尝试执行以下操作:

import sys
sys.float_info.max

You would get: 1.7976931348623157e+308 您会得到:1.7976931348623157e + 308

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM