浮点加法说明 [英] Floating Point Addition Explanation

查看:59
本文介绍了浮点加法说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习浮点加法,我很困惑.我正在处理的示例如下:

I'm learning floating-point addition and I'm rather confused at one part. The example I'm working with goes like this:

(假设使用8位计算机,指数超出3)

(Assume 8 bit machine, exponent excess-3)

x = 6.75 = 01011011
y = -10 = 11100100

反规范化并使用相同的指数给出:

Denormalise and use same exponents gives:

x = 1.1011 x 2^2 = 0.1101 x 2^3
y = -1.0100 x 2^3

添加/减去尾数:

01101 + -10100 = -00111

我不太了解01101 + -10100 = -00111.有人可以给我解释一下吗?

I don't quite get how 01101 + -10100 = -00111. Can someone explain this to me please?

推荐答案

首先,缩放1.1011•2 2 应该得到0.11011•2 3 ,而不是0.1101•2 3 .提早丢弃比特是错误的.

First, scaling 1.1011•22 should give 0.11011•23, not 0.1101•23. It is an error to discard bits early.

但是,按照它的方式,我们要计算01101 + -10100.将较大的数字放在较小的数字之上,并请记住,由于较大的数字为负,因此结果必须为负:

However, given the way it is, we want to calculate 01101 + -10100. Put the larger number above the smaller number and remember that, because the larger number is negative, the result must be negative:

1 0 1 0 0
0 1 1 0 1
_________

现在减去小学方式.在右边,我们从0减去1.这需要从左边的数字减去1,因此我们从10减去1(0加上借来的值)并标记借位:

Now subtract the elementary-school way. On the right, we subtract 1 from 0. This requires borrowing from the digit to the left, so we subtract 1 from 10 (0 plus the borrowed value) and mark the borrow:

1 0 1 0'0
0 1 1 0 1
_________
        1

现在,我们从-1(0减去借位)中减去0.这需要再次借款,因此我们从1中减去0(0减去1的借款再加上10的新借款):

Now we subtract 0 from -1 (0 minus the borrow). This requires borrowing again, so we subtract 0 from 1 (0 minus the borrow of 1 plus the new borrow of 10):

1 0 1'0'0
0 1 1 0 1
_________
      1 1

然后从0(1减去借来的1)中减去1.我们再次借钱,所以我们从10中减去1:

Then 1 from 0 (1 minus the borrowed 1). We borrow again, so we subtract 1 from 10:

1 0'1'0'0
0 1 1 0 1
_________
    1 1 1

然后从-1(0减去借来的1)中减去1.我们再次借钱,所以我们从1中减去1(0减去借来的1再加上新借来的10):

Then 1 from -1 (0 minus the borrowed 1). We borrow again, so we subtract 1 from 1 (0 minus the borrowed 1 plus the newly borrowed 10):

1'0'1'0'0
0 1 1 0 1
_________
  0 1 1 1

然后从0开始计算0(1减去借来的1).最后,没有新的借用,而我们有:

Then 0 from 0 (1 minus the borrowed 1). Finally, there is no new borrow, and we have:

1'0'1'0'0
0 1 1 0 1
_________
0 0 1 1 1

我们记得这是负数,所以结果是-00111.

We remember this is negative, so the result is -00111.

这篇关于浮点加法说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆