gpt4 book ai didi

将 0.125 转换为 7 位浮点格式

转载 作者:太空宇宙 更新时间:2023-11-04 02:04:57 24 4
gpt4 key购买 nike

   Suppose we have a 7-bit computer that uses IEEE floating-point arithmetic where a 
floating point number has 1 sign bit, 3 exponent bits, and 3 fraction bits. All of the bits in
the hardware work properly.

Recall that denormalized numbers will have an exponent of 000, and the bias for a 3-bit
exponent is 3.

要转换的数字是-0.125

这是我的尝试

转换为二进制形式

0.001

移动小数点

0001.0 

所以 E = -3 因为我们将小数点右移了 3 次

E = e -bias 
-3 = e -3

所以e = 0和 M = 0?这给了我

1 000 000

这是错误的。正确答案应该是 1 000 100

我做错了什么?

最佳答案

偏差为 3,因此 1.0 的指数存储为 3。因此,要获得 1/8,您需要存储零,但这是非正规数的表示。非正规数必须显式存储前导位,以便尾数变为 100 而不是 000。需要存储 1 会导致精度下降,这是非规范化的症状。

关于将 0.125 转换为 7 位浮点格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21847119/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com