结束携带原因 [英] Reason for end around carry to do

查看:105
本文介绍了结束携带原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,如果最高位带有进位,则r基数的r-1补码应该以进位结束。

I know that the r-1 complement for r-base number should do end around carry if the highest bit has carry.

但是我不知道为什么应该做到这一点。

But I cannot figure out why it should do it.

我只能想到这可能是两个表示为零的原因。

I merely can think about it is the reason may be about the two representations for zero.

ex:

 1 1 1 0    (-1)
 0 1 0 1    (+5)  
 ===============
10 0 1 1  =====>(0 1 0 0)
I just can explain it from the result that because its sum is positive, and 1's complement has two representations, so it should add one.

ex:

 1 1 1 0    (-1)
 1 0 1 0    (-5)  
 ===============
11 0 1 1  =====>(1 0 0 1)
And I cannot explain it why should add one.

真正结束结转的真正原因是什么?

What is the really reason for end around carry?

Thx,供您阅读。

推荐答案

环行进位实际上很简单:它会改变如果您认为数字是无符号的,则从r n 到r n -1的加法运算。为简化起见,让我们讨论二进制。

End-around carry is actually rather simple: it changes the modulus of the addition operation from rn to rn–1, if you think of the numbers as unsigned. To simplify things, let's talk about binary.

让我们使用四位二进制补码算术来计算(-2)+(-4):

Let's compute (-2) + (-4) using four-bit two's complement arithmetic:


  1 1 1 0    (-2)
+ 1 1 0 0  + (-4)
---------  ------
1 1 0 1 0    (-6)

让进位位保持原位现在。如果将数字视为无符号整数,我们将计算出14 + 12 =26。但是,加法是对16取模,因此我们得到10,这是无符号数字,代表-6(正确的结果)。

Let's keep the carry bit where it is for now. If you look at the numbers as unsigned integers, we're computing 14 + 12 = 26. However, addition is done modulo 16, so we get 10, which is the unsigned number which represents -6 (the correct result).

在一个补码中,数字具有不同的表示形式:

In ones' complement, the numbers have different representations:


  1 1 0 1    (-2)
+ 1 0 1 1  + (-4)
---------  ------
1 1 0 0 0    (-6)

再次,让进位保持在原位。如果您将数字看成无符号整数,则我们计算的是13 + 11 =24。但是,由于回绕进位,加法运算取模15,所以我们最后得到9,它表示-6(正确

Again, let's keep the carry bit where it is. If you look at the numbers as unsigned integers, we're computing 13 + 11 = 24. However, due to the wrap-around carry, addition is done modulo 15, so we end up with 9, which represents -6 (the correct result).

所以在四位二进制补码中,-2等于14模16,-4等于12模16,而-6等于10模16。

So in four-bit two's complement, -2 is equivalent to 14 modulo 16, -4 is equivalent to 12 modulo 16, and -6 is equivalent to 10 modulo 16.

在四位补码中,-2等于13模15,-4等于11模15,而-6是等于9模15。

And in four-bit ones' complement, -2 is equivalent to 13 modulo 15, -4 is equivalent to 11 modulo 15, and -6 is equivalent to 9 modulo 15.

有符号零:之所以得到有符号零是因为四位中有16个可能的数字,但是如果您要进行15模运算,则0和15是等效的。就是这么多。

Signed zero: The reason you get "signed zero" is because there are 16 possible numbers in four bit, but if you're doing modulo-15 arithmetic, then 0 and 15 are equivalent. That's all there is to it.

这篇关于结束携带原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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