Difference between 1’s Complement representation and 2’s Complement representation Technique
Prerequisite – Representation of Negative Binary Numbers
1’s complement of a binary number is another binary number obtained by toggling all bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0. Examples:
Let numbers be stored using 4 bits 1's complement of 7 (0111) is 8 (1000) 1's complement of 12 (1100) is 3 (0011)
2’s complement of a binary number is 1 added to the 1’s complement of the binary number. Examples:
Let numbers be stored using 4 bits 2's complement of 7 (0111) is 9 (1001) 2's complement of 12 (1100) is 4 (0100)
These representations are used for signed numbers.
The main difference between 1′ s complement and 2′ s complement is that 1′ s complement has two representations of 0 (zero) — 00000000, which is positive zero (+0), and 11111111, which is negative zero (-0); whereas in 2′ s complement, there is only one representation for zero — 00000000 (0) because if we add 1 to 11111111 (-1), we get 100000000, which is nine bits long. Since only eight bits are allowed, the left-most bit is discarded(or overflowed), leaving 00000000 (-0) which is the same as positive zero. This is the reason why 2′ s complement is generally used.
Another difference is that while adding numbers using 1′ s complement, we first do binary addition, then add in an end-around carry value. But, 2′ s complement has only one value for zero and doesn’t require carry values.
Range of 1’s complement for n bit number is from -2n-1-1 to 2n-1-1 whereas the range of 2’s complement for n bit is from -2n-1 to 2n-1-1.
There are 2n-1 valid numbers in 1’s complement and 2n valid numbers in 2’s complement.
Difference between 1’s Complement representation and 2’s Complement representation in tabular form:
Criteria | 1’s Complement | 2’s Complement |
Definition | The 1’s complement of a binary number is obtained by inverting all its bits. | The 2’s complement of a binary number is obtained by adding 1 to the 1’s complement of the number. |
Range of values that can be represented with n bits | From -2^(n-1) + 1 to 2^(n-1) – 1 | From -2^(n-1) to 2^(n-1) – 1 |
Number of representations for zero | Can be represented in two ways (all 0s and all 1s). | Can be represented in only one way (all 0s). |
Addition of positive and negative numbers | Same as unsigned binary addition. | Same as unsigned binary addition. |
Subtraction of numbers | Subtract the smaller number from the larger one, then add a sign bit to the result. | Add the negative number to the positive one using binary addition. |