[英]What bit pattern represents the max value for double precision floating point?
I'm wondering how the max value is represented in 64 bits of double precision floating point. 我想知道最大值如何以64位双精度浮点表示。 I assume it's represented with all 1's in exponent and mantissa like so:
我假设它以指数和尾数全部用1表示:
0 11111111111 1111111111111111111111111111111111111111111111111111
If so, then why Number.MAX_VALUE = 1.7976931348623157e+308
shows the exponent of 308
, instead of 1024
decoded from 11111111111
? 如果是这样,那么为什么
Number.MAX_VALUE = 1.7976931348623157e+308
显示的指数308
,而不是1024
的解码11111111111
? Is the bits pattern different? 位模式是否不同?
指数是308,因为那是1.7976931x 10 ^ 308,也就是1x 2 ^ 1024。
The exponent is 308 since 308 is 1024 / (log 10 / log 2)
. 因为308是
1024 / (log 10 / log 2)
所以指数是308。
Remember that the 1024 is a binary exponent, but 308 is a denary exponent. 请记住,1024是二进制指数,而308是拒绝指数。
308 is decimal exponent while double uses powers of two. 308是十进制指数,而double使用2的幂。
Secondly max value exponent is reserved for infinity and NaN. 其次,最大值指数保留给无穷大和NaN。 Max-1 is the max exponent for regular number.
Max-1是常规数的最大指数。 Therefore the max number is written as:
因此,最大数量写为:
01111111 11101111 11111111 11111111 11111111 11111111 11111111 11111111
Ie 0
sign bit, 2046
as exponent value (note that 1023
means actually zero exponent so 2046
means exponent of 1023
) and mantissa all ones ( 1.11111(52 times)
in binary, the first one is hidden), in other words 1.11111(52 times)*2^1023
. 即
0
符号位, 2046
为指数值(请注意1023
表示实际上为零指数,因此2046
表示1023
指数)尾数均为1(二进制为1.11111(52 times)
,第一个被隐藏),换言之1.11111(52 times)*2^1023
。
Converted to decimal it's (2-(2^-52))*2^1023
which is about 1.79769313486231*10^308
. 转换为十进制是
(2-(2^-52))*2^1023
,大约是1.79769313486231*10^308
。
For the double/float formats you can find very precise information on wiki . 对于double / float格式,可以在Wiki上找到非常精确的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.