Subtraction
- The two's complement notation system is typically used to perform subtraction by using the rules of addition, i.e., preserving addition, where, for example, (5 - 4) is equivalent to (5 + (-4)).
The Basic Strategy of Performing Subtraction by Preserving Addition:
- Represent both values as positive signed numbers;
- Decide the minimum bit length required.
- Convert the subtrahand (quantity to be subtracted) into its negative representation using either of the two methods of 2's complement convertion discussed previously.
- Then add the two values together.
So, using minimally required number of bits including the sign bit we can perform (5-4) as below:
510 converts to 0101 (at least a 4-bit pattern including the + sign is required at the outset)
and,410 converts to 0100.
so -410 must be 1100 (after converting the +ive number to its -tive complement)
Add these two together:
0101 (+5) |
+1100 = +(-4) |
|
- But in this case, we have limited ourselved to a fixed length of 4 bits in this example.
- That being the case, the last carry bit (the 5th bit) must be "truncated" or discarded as overflow (there is not enough bits allocated).
- The resulting answer is then: 0001 or the signed decimal equivalent of +1