Half subtractor
A half subtractor is a combinational circuit that subtracts one bit from another and produces a difference bit and a borrow bit, using an XOR gate for the difference and an AND gate with one inverted input for the borrow.
Subtracts one bit from another. Two gates and an inverter.
Circuit diagram
Toggle the inputs and follow the signals: green wires are high, red are low. The highlighted row of the truth table below is the one you have set.
Truth table
| A | B | diff | borrow |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
Boolean expressions
- diff
- a ⊻ b one XOR gate, the same as the half adder sum
- borrow
- ¬a ∧ b borrow when taking 1 from 0
How it works
Subtracting B from A one bit at a time has the same four cases as adding, and the difference column is the same XOR. What changes is the carry: subtraction borrows, and only one case needs it, 0 minus 1. So the borrow is 1 exactly when A is 0 and B is 1, which is ¬A ∧ B rather than the adder's A ∧ B.
Where it is used
- The least significant column of a subtractor, where nothing has been borrowed yet.
- The rightmost column of a decrementer, which is a chain of these with a constant 1 fed into that column.
- Showing why adders and subtractors are the same circuit apart from one inverted input.
Build it
Two toggles, an XOR for the difference, and a NOT into an AND for the borrow. Compare it to the half adder: only the NOT is new.
Or draw it from the expressions above with the circuit diagram generator, in either symbol standard, and export it as SVG, PNG, Verilog or VHDL.
Reference card
The diagram above as an image, black on white, for notes or a slide.
Click to download: Half subtractor circuit diagramQuestions about the half subtractor
What is the truth table of a half subtractor?
Four rows. 0 minus 0 is difference 0, borrow 0; 0 minus 1 is difference 1 with a borrow of 1, because taking 1 from 0 needs a 1 borrowed from the next column; 1 minus 0 is difference 1, borrow 0; and 1 minus 1 is difference 0, borrow 0. The difference column is A ⊕ B and the borrow column is ¬A ∧ B.
What is the difference between a half adder and a half subtractor?
The sum and difference outputs are identical: both are XOR. The carry and borrow differ in one row. An adder carries when both inputs are 1, so the carry is A ∧ B; a subtractor borrows when A is 0 and B is 1, so the borrow is ¬A ∧ B. One inverter turns one into the other.