Subtraction by adding the complement: 1101 − 0110 — binary arithmetic
exam standardone circuit for both operations
Answer
0111
Why this example is worth doing
The same subtraction as the earlier example, done by inverting the subtrahend and adding with a carry-in of one. Getting the identical answer by a completely different route is the point: it is why processors contain an adder and no subtractor. The page shows the discarded final carry and explains that its presence, rather than being an error, is what signals that the result is non-negative.
Try your own input in the Binary arithmetic. Add, subtract, multiply and divide in binary with every carry and borrow shown.
How the answer is reached
1101 - 0110 (4-bit, two's complement)
| operand | bits | hex | unsigned | signed |
|---|---|---|---|---|
| A | 1101 | 0xD | 13 | -3 |
| B | 0110 | 0x6 | 6 | 6 |
Method A — borrow propagation.
| row | 3 | 2 | 1 | 0 |
|---|---|---|---|---|
| borrow in | 1 | 1 | 0 | 0 |
| A | 1 | 1 | 0 | 1 |
| - B | 0 | 1 | 1 | 0 |
| result | 0 | 1 | 1 | 1 |
C = 0 · V = 1 · N = 0 · Z = 0
Method B — add the two’s complement of B, then discard the final carry.
NOT B1001
NOT B + 11010— the two’s complement of B
| row | 3 | 2 | 1 | 0 |
|---|---|---|---|---|
| carry in | 0 | 0 | 1 | 1 |
| A | 1 | 1 | 0 | 1 |
| + B | 1 | 0 | 0 | 1 |
| result | 0 | 1 | 1 | 1 |
carry in 1 · carry out 1 (discarded)
reading the final carry1: no borrow, A >= B as unsigned
signed-3 - 6 = -9, kept as 7— V = 1: the signed answer is wrong
Both methods are shown because curricula grade different ones. The final carry of method B is always the complement of the borrow-out of method A.