Complements are used in digital computers in order to simply the subtraction operation and for the logical manipulations. For the Binary number (base-2) system, there are two types of complements: 1’s complement and 2’s complement.
There is a simple algorithm to convert a binary number into 1’s complement. To get 1’s complement of a binary number, simply invert the given number.
There is a simple algorithm to convert a binary number into 2’s complement. To get 2’s complement of a binary number, simply invert the given number and add 1 to the least significant bit (LSB) of given result.
These differences are given as following below −
1’s complement | 2’s complement |
---|---|
To get 1’s complement of a binary number, simply invert the given number. | To get 2’s complement of a binary number, simply invert the given number and add 1 to the least significant bit (LSB) of given result. |
1’s complement of binary number 110010 is 001101 | 2’s complement of binary number 110010 is 001110 |
Simple implementation which uses only NOT gates for each input bit. | Uses NOT gate along with full adder for each input bit. |
Can be used for signed binary number representation but not suitable as ambiguous representation for number 0. | Can be used for signed binary number representation and most suitable as unambiguous representation for all numbers. |
0 has two different representation one is -0 (e.g., 1 1111 in five bit register) and second is +0 (e.g., 0 0000 in five bit register). | 0 has only one representation for -0 and +0 (e.g., 0 0000 in five bit register). Zero (0) is considered as always positive (sign bit is 0) |
For k bits register, positive largest number that can be stored is (2(k-1)-1) and negative lowest number that can be stored is -(2(k-1)-1). | For k bits register, positive largest number that can be stored is (2(k-1)-1) and negative lowest number that can be stored is -(2(k-1)). |
end-around-carry-bit addition occurs in 1’s complement arithmetic operations. It added to the LSB of result. | end-around-carry-bit addition does not occur in 2’s complement arithmetic operations. It is ignored. |
1’s complement arithmetic operations are not easier than 2’s complement because of addition of end-around-carry-bit. | 2’s complement arithmetic operations are much easier than 1’s complement because of there is no addition of end-around-carry-bit. |
Sign extension is used for converting a signed integer from one size to another. | Sign extension is used for converting a signed integer from one size to another. |