为什么数字(不能)在双精度IEEE754中表示? [英] Why number are (not) representable in double precision IEEE754?
问题描述
我对 IEEE754 双精度感到困惑,我考虑了两个问题:
1.
为什么间隔-2 54 ,-2 54 + 2,-2 54 +4 ... 2 54 是可代表的吗?
I am confused on IEEE754 double precision, I consider two questions:
1.
Why each number from interval -254, -254+2, -254+4...254 is representable ?
2..为什么2 54 +2无法表示?
2. Why 254+2 is not representable ?
你能帮我吗?我了解 IEEE754 的工作方式-但是,看到存在问题.
Can you help me ? I understand way of working IEEE754 - however, I have a problem with seeing it.
推荐答案
IEEE 754 double的有效位(或尾数)中有53位. − 2 54 可以精确表示为,
There are 53 bits in the significand (or mantissa) of an IEEE 754 double. −254 can be exactly represented, as
mantissa: 1.00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 00 (bin)
exponent: 54
sign: 1
现在让我们暂时忘记符号位.与该解释无关.因此,假设我们有+2 54 .
Now let's forget the sign bit for a moment. It is irrelevant for this explanation. So assume we have +254.
有了这个指数,有效数字的 最低-最右- 位的值为2 -52 * 2 54 =4.因此2 54 + 4编码为:
With this exponent, the lowest -- rightmost -- bit of the significand has the value 2-52 * 254 = 4. So 254 + 4 is encoded as:
mantissa: 1.00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 01 (bin)
exponent: 54 ^
lowest bit
但两者之间没有任何价值.因此,您无法编码2 54 + 2 .
But there is no value inbetween. So you cannot encode 254 + 2.
为什么− 2 54 + 2 没问题?因为这与−(2 54 − 2)相同,所以表示为:
Why is this not a problem for −254 + 2? Because that is the same as −(254 − 2), and that is represented as:
mantissa: 1.11111 11111 11111 11111 11111 11111 11111 11111 11111 11111 11
exponent: 53 !!
sign: 1
指数53表示您的步长为2 -52 * 2 53 =2.然后,向0的下一个值是:
And the exponent 53 means you have steps of 2-52 * 253 = 2. The next value toward 0 is then:
mantissa: 1.11111 11111 11111 11111 11111 11111 11111 11111 11111 11111 10
exponent: 53
sign: 1
是− 2 54 + 4,或者实际上是−(2 54 − 4).然后您可以像这样继续下去,直到达到− 2 53 .
which is −254 + 4, or actually −(254 − 4). And you can go on like that until you reach −253.
这篇关于为什么数字(不能)在双精度IEEE754中表示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!