2013-05-10 77 views
2

补充我们假设4位2的补体系统是用来表示正负数发现2的负没有

Suppose we have to find 2's complement of no. 3 
We can subtract this no. with 2^4 
       that is ,     
          = 2^4 - 3 
          = 13 
          =1101 (which represent -3 , in 2's complement system) 

//* there is another way of finding 2's complement , taking 1's complemen of the 
    number and add 1 to it. 

在这本书中的规则是考虑到减去两个没有。

规则:减去两个没有X和Y,即X - Y,形式2的补码号。 Y并将其添加到X.

假设我们必须减去两个no。 (-7)和(-5),那么根据规则,我们需要找到no(-5)的2的补码,然后将它加到(-7)。

电子书解决方案:

enter image description here

我需要知道,2的-5补怎么0101

回答

1

要找到2的一个数字,你的补充:

  • 反转位
  • add 1

实施例(2S 5补码):

  • 5 =二进制

  • 0101反转位:

    1010

  • 添加1:

    < 1011 - 补体的5 2S是1011

例(-5 2S补码):以二进制

    • -5 = 1011反转位:

      0100

    • 添加1:

      0101 < - 2秒-5补充是0101

  • +0

    但无不是5,这是-5,以2的补体系统,为-5位表示是1011 。 – siddstuff 2013-05-10 20:39:47

    +0

    如果对负数执行相同的二进制补码操作,您将得到正数。 – CraigTeegarden 2013-05-10 20:40:25

    +0

    ,我们如何通过从2^4中减去它来找到相同的值? – siddstuff 2013-05-10 20:42:17