2

我们假设使用 4bit 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.

在书中给出的规则是减去两个没有。

规则: 减去两个 no X 和 Y ,即 X - Y ,形成 no 的 2 补码。Y并将其添加到 X。

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

图书解决方案:

在此处输入图像描述

我需要知道,-5 的 2 的补码是 0101。

4

1 回答 1

1

要找到一个数字的 2 的补码,您:

  • 反转位
  • 加 1

示例(5 的 2 秒补码):

  • 5 =0101二进制

  • 反转位:

    1010

  • 添加1:

    1011<- 5 的 2s 补码是1011

示例(-5 的 2s 补码):

  • -5 =1011二进制

  • 反转位:

    0100

  • 添加1:

    0101<- -5 的 2s 补码是0101

于 2013-05-10T20:32:26.850 回答