【发布时间】:2017-02-26 04:55:49
【问题描述】:
我觉得我不是很了解overflow 和underflow 的概念。我问这个问题是为了澄清这一点。我需要在最基本的层面上用比特来理解它。让我们使用1 byte - 1 位符号、3 位指数和4 位尾数的简化浮点表示:
0 000 0000
我们可以存储的最大指数是111_2=7 减去偏置K=2^2-1=3 得到4,它保留给Infinity 和NaN。最大数的指数为3,即偏移二进制下的110。
所以最大数量的位模式是:
0 110 1111 // positive
1 110 1111 // negative
当指数为零时,该数字是次正规的并且具有隐含的0 而不是1。所以最小数的位模式是:
0 000 0001 // positive
1 000 0001 // negative
我找到了单精度浮点的这些描述:
Negative numbers less than −(2−2−23) × 2127 (negative overflow)
Negative numbers greater than −2−149 (negative underflow)
Positive numbers less than 2−149 (positive underflow)
Positive numbers greater than (2−2−23) × 2127 (positive overflow)
其中我只了解导致+Infinity的正溢出,示例如下:
0 110 1111 + 0 110 1111 = 0 111 0000
谁能使用我上面概述的位模式演示其他三种溢出和下溢情况?
【问题讨论】:
-
也许this question 会有所帮助?
-
@evolutionxbox,谢谢,但我已经知道了
-
那我会密切关注你的问题...
标签: javascript floating-point ieee-754