我正在尝试找出使用浮点值的规范化表示的一些细节。
据我了解,IEEE-754 表示的工作方式如下:
1.{significand} * 2^{exponent}
对于单精度,尾数为24位,指数为8位。
我试图将其分解为本质上是指数支持的每个数字范围内可用的“插槽”数量,例如:
[Exponent=0] 0.0 - 1.0 : 2^23 values
[Exponent=1] 1.0 - 2.0 : 2^23 values
[Exponent=2] 2.0 - 4.0 : 2^23 values
[Exponent=3] 4.0 - 8.0 : 2^23 values
我试图证明在使用量化时,如果我感兴趣的范围限制在 0.0 - 1.0,我可以使用 2^24 位来表示这个数字,并且在删除指数,这可以很容易地转换为完整的浮点表示。此外,为了清楚地说明在使用 float 时,接近零的精度比远离零的精度更高,因为感觉这可能很容易理解。
我不太清楚的一个领域是支持的指数是 -127 到 126,负数部分如何工作? 1.5 * 2^-1 明显与 0.0 - 1.0 范围重叠。
最后,我知道有效数字中的一位用于符号,但是隐藏位代表什么,这会影响每个范围内可用的“插槽”数量吗?
最佳答案
我想你的表格是错误的。应该是:
.... [Exponent=-3] 0.125 - 0.25 : 223 values [Exponent=-2] 0.25 - 0.5 : 223 values [Exponent=-1] 0.5 - 1.0 : 223 values [Exponent=0] 1.0 - 2.0 : 223 values [Exponent=1] 2.0 - 4.0 : 223 values [Exponent=2] 4.0 - 8.0 : 223 values ....
或者更准确地说:
.... [Exponent=-3] 0.125 ≤ x < 0.25 : 223 values [Exponent=-2] 0.25 ≤ x < 0.5 : 223 values [Exponent=-1] 0.5 ≤ x < 1.0 : 223 values [Exponent=0] 1.0 ≤ x < 2.0 : 223 values [Exponent=1] 2.0 ≤ x < 4.0 : 223 values [Exponent=2] 4.0 ≤ x < 8.0 : 223 values ....
关于floating-point - 在浮点表示法中,不同范围最多可表示多少个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25057050/