Computer Logical Organization 简明教程

Complement Arithmetic

在数字计算机中使用补码是为了简化减法运算和逻辑运算。对于每个基数-r 系统(基数 r 表示数字系统的基数),共有两种类型的补码。

Complements are used in the digital computers in order to simplify the subtraction operation and for the logical manipulations. For each radix-r system (radix r represents base of number system) there are two types of complements.

S.N.

Complement

Description

1

Radix Complement

The radix complement is referred to as the r’s complement

2

Diminished Radix Complement

The diminished radix complement is referred to as the (r-1)'s complement

Binary system complements

由于二进制系统以 r = 2 为基数。因此,二进制系统的两种类型的补码为 2 补码和 1 补码。

As the binary system has base r = 2. So the two types of complements for the binary system are 2’s complement and 1’s complement.

1’s complement

一个数字的 1 补码可以通过将所有 1 改为 0,并将所有 0 改为 1 来获得。这称为取补码或 1 补码。1 补码示例如下。

The 1’s complement of a number is found by changing all 1’s to 0’s and all 0’s to 1’s. This is called as taking complement or 1’s complement. Example of 1’s Complement is as follows.

1s complement

2’s complement

二进制数的 2 补码是通过将 1 补码的最低有效位 (LSB) 加 1 获得的。

The 2’s complement of binary number is obtained by adding 1 to the Least Significant Bit (LSB) of 1’s complement of the number.

2 补码 = 1 补码 + 1

2’s complement = 1’s complement + 1

2 补码示例如下。

Example of 2’s Complement is as follows.

2s complement