开发者

Floating point mantissa bias

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-b开发者_如何学Cit 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 = ? 


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜