2013-05-10 48 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