浮点尾数偏差

发布于 2024-08-22 10:22:29 字数 243 浏览 4 评论 0原文

有谁知道如何出去解决这个问题?

* 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧竹 2024-08-29 10:22:29

要完成此练习,您只需按照添加步骤进行操作,如下所示:
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

只是一片海 2024-08-29 10:22:29
S EEEEE MMMMMMMM
0 11001 10000000 a
1 11001 10000000 b
0 10001 10000000 c

0 11001 00000000 c, denormalized (uh oh!)

如果我做对了,看起来你不能将 c 反规范化为 a 的指数,所以你最终会用相同的指数将 1 加到 -1 上,所以你最终会得到 0。我相信这是一个关于以浮点格式将小数加到大数的局限性。

我将把第二个问题留给你......

S EEEEE MMMMMMMM
0 11001 10000000 a
1 11001 10000000 b
0 10001 10000000 c

0 11001 00000000 c, denormalized (uh oh!)

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文