Addition and subtraction of 2’s complement signed binary numbers are important learning concepts, as digital computers use 2’s complement representation. 2’s complement arithmetic follows all the basic rules of binary arithmetic. However, a few tricks need to be learned so that we can get the correct result in its 2’s complement form. This article discusses all possible cases of addition. The four possible cases are as below:
- Both the numbers are positive (the result will be positive)
- Negative number with a smaller magnitude than the positive number (the result will be positive)
- Negative number with a larger magnitude than the positive number (the result will be negative)
- Both the numbers are negative (the result will be negative)
Note that the second case is equivalent to subtracting a small positive number from a large positive number. Moreover, the third case is equivalent to subtracting a large positive number from a small positive number. So, we would not discuss the 2’s complement subtraction separately. The second and third cases of addition will cover the same.
Learn Addition of 1’s Complement Signed Binary Numbers with examples. |
We will discuss all the above four different cases of addition using examples. We will consider 8-bit numbers (1 bit for sign and 7 bits for magnitude) for our example. The two numbers in an addition is known as addend and augend, and the result is known as sum.
Important Rule: Add the two numbers using basic rules of binary addition, and discard any final carry bit. The final carry is the bit generated out of the sign-bit position. |
Both the numbers are positive
Example: 8 + 5 = ?
2’s complement representation of 8 = 00001000
2’s complement representation of 5 = 00000101
Since 8 and 5 are positive, so their 2’complement representation will be the same as its true (uncomplemented) form.
The sum is a positive number.
Negative number with smaller magnitude than the positive number
Example: 8 + (-5) = ?
This example can also be read as 8 – 5 = ?
Tip: So, whenever you would find such a subtraction question, you can convert the same to an addition question as in this example. Then, you can follow the method shown here. |
2’s complement representation of 8 = 00001000
2’s complement representation of -5 = 11111011
The sum is a positive number.
Negative number with larger magnitude than the positive number
Example: -8 + 5 = ?
2’s complement representation of -8 = 11111000
2’s complement representation of 5 = 00000101
The sum is a negative number.
Both the numbers are negative
Example: -8 + (-5) = ?
2’s complement representation of -8 = 11111000
2’s complement representation of -5 = 11111011
The sum is a negative number.
The examples taken in this article are carefully chosen so that the overflow condition does not arise. Overflow occurs if the carries into and out of MSB are different. Overflow, in the case of signed binary arithmetic, is an unwanted condition, as it results in an incorrect sum. Thus, it is important to learn about Overflow and how to avoid it.