浮点尾数偏差
有谁知道如何出去解决这个问题?
* a = 1.0 × 2^9
* b = −1.0 × 2^9
* c = 1.0 × 2^1
使用浮点(表示形式使用 14 位格式,5 位表示偏置为 16 的指数,8 位归一化尾数,单个符号位表示数字),执行以下两个计算,密切注意操作顺序。
* b + (a + c) = ?
* (b + a) + c = ?
Does anybody know how to go out solving this problem?
* a = 1.0 × 2^9
* b = −1.0 × 2^9
* c = 1.0 × 2^1
Using the floating-point (the representation uses a 14-bit format, 5 bits for the exponent with a bias of 16, a normalized mantissa of 8 bits, and a single sign bit for the number), perform the following two calculations, paying close attention to the order of operations.
* b + (a + c) = ?
* (b + a) + c = ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要完成此练习,您只需按照添加步骤进行操作,如下所示:
http://en.wikipedia.org/wiki/Floating_point#Addition_and_subtraction
To go through this exercise, you just follow the addition steps, as explained e.g. there:
http://en.wikipedia.org/wiki/Floating_point#Addition_and_subtraction
如果我做对了,看起来你不能将 c 反规范化为 a 的指数,所以你最终会用相同的指数将 1 加到 -1 上,所以你最终会得到 0。我相信这是一个关于以浮点格式将小数加到大数的局限性。
我将把第二个问题留给你......
If I'm doing this right, it looks like you can't denormalize c to a's exponent, so you end up adding 1 to -1 with the same exponent, and so you end up with 0. I believe this is a lesson on the limitations of adding a small number to a large one in a floating point format.
I will leave the second problem to you...