Subtraction by two's complement: 1011 − 0110 — adders
exam standardone adder does both operations
Answer
0101
Why this example is worth doing
Invert the subtrahend, force the carry-in to 1, and the same adder subtracts. That is why processors have an adder and not a subtractor, and it is the payoff of the two's complement representation. The page shows the XOR gates that conditionally invert — the controlled-inverter identity from the XOR page — and links to the two's complement tool for the representation itself.
Try your own input in the Half adder & full adder. Truth tables, K-maps and circuits for both adders, and the ripple-carry chain.
How the answer is reached
1011 - 0110 (4-bit, unsigned)
| operand | bits | hex | unsigned | signed |
|---|---|---|---|---|
| A | 1011 | 0xB | 11 | -5 |
| B | 0110 | 0x6 | 6 | 6 |
Method A — borrow propagation.
| row | 3 | 2 | 1 | 0 |
|---|---|---|---|---|
| borrow in | 1 | 0 | 0 | 0 |
| A | 1 | 0 | 1 | 1 |
| - B | 0 | 1 | 1 | 0 |
| result | 0 | 1 | 0 | 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 | 1 | 1 | 1 |
| A | 1 | 0 | 1 | 1 |
| + B | 1 | 0 | 0 | 1 |
| result | 0 | 1 | 0 | 1 |
carry in 1 · carry out 1 (discarded)
reading the final carry1: no borrow, A >= B as unsigned
signed-5 - 6 = -11, kept as 5— 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.