digiwleeaLearn
Open the lab →

Full subtractor

One column of the borrow chain

7 min read

A full subtractor subtracts three bits, the minuend bit A minus the subtrahend bit B minus a borrow-in, producing a Difference bit and a Borrow out. Chaining one per bit position, borrow-out into borrow-in, subtracts whole binary numbers exactly as chained full adders add them.

The half subtractor handles the rightmost column of a subtraction, where nothing is owed yet. Every other column has to settle a possible debt from the column below it: subtract A - B, and *also* pay back the borrow that column raised. So a real subtraction column takes three inputs: A, B, and Bin (borrow-in), and produces a Difference D plus a Bout that passes any new debt one column up. This is the full adder's mirror image, column for column.
Work it on paper the way you subtract decimals. In each column you compute A - B - Bin. If the result is 0 or 1, write it down and owe nothing. If it goes negative, borrow a 2 from the next column: write down the result plus 2, and raise Bout = 1. For example 0 - 1 - 1 = -2: borrow a two, write -2 + 2 = 0, owe 1. And 1 - 1 - 1 = -1: borrow, write -1 + 2 = 1, owe 1.
ABBinDBout
00000
00111
01011
01101
10010
10100
11000
11111
Full subtractor truth table: each row computes A - B - Bin. D is 1 when an odd number of the three inputs are 1, exactly like the full adder's Sum. Bout is 1 whenever B + Bin exceeds A.
Two patterns worth memorizing. First, D = A XOR B XOR Bin, the identical parity function as the full adder's Sum: the difference column of subtraction and the sum column of addition are the same gate. Second, the borrow mirrors the carry with one inversion: the full adder's COUT is 1 when at least two of A, B, CIN are 1, and the full subtractor's Bout is 1 when at least two of NOT A, B, Bin are 1. Invert the minuend and the carry logic *becomes* the borrow logic.
D = A B Bin
Bout = (A'·B) + (((A B)')·Bin)

Building it from two half subtractors and an OR

Just as a full adder is two half adders plus an OR, a full subtractor is two half subtractors plus an OR. The first half subtractor computes A - B; the second subtracts Bin from that partial result. Each stage can raise a borrow, and the two borrows merge through the OR. They are never both 1 at once (the first borrows only when A = 0, B = 1, and in that case the partial difference is 1, which the second stage can always cover), so a plain OR is enough.
  1. Place two half subtractor parts (HS1 and HS2) and one OR part.
  2. Feed A and B into HS1. It produces a partial difference d1 = A XOR B and a borrow b1.
  3. Feed d1 and Bin into HS2 (with d1 as the minuend). It produces the final Difference D and a borrow b2.
  4. Feed b1 and b2 into the OR gate. Its output is Bout.
  5. Label HS2's difference D and the OR output Bout.
Full subtractor from two half subtractors (each an XOR plus a NOT-AND borrow) and one OR merging the borrows. Step through the eight rows, or follow the gate-by-gate version in how to build a full subtractor.

Chaining columns: the ripple-borrow subtractor

Now subtract whole numbers. Line up one full subtractor per bit, wire each Bout into the Bin of the next column to the left, and tie the rightmost Bin to 0. Here is 0110 - 0011 (six minus three), column by column from the right:
  1. Column 0: 0 - 1 - 0 goes negative, so borrow: D = 1, Bout = 1.
  2. Column 1: 1 - 1 - 1 = -1, borrow again: D = 1, Bout = 1. The debt ripples leftward.
  3. Column 2: 1 - 0 - 1 = 0, the debt is absorbed: D = 0, Bout = 0.
  4. Column 3: 0 - 0 - 0: D = 0, Bout = 0. Read the result 0011, which is three. Six minus three is three.
Watch the final borrow. Subtract the other direction, 0011 - 0101 (three minus five), and the chain outputs D = 1110 with the last Bout = 1. As an unsigned number 1110 reads fourteen, which looks wrong, but it is not garbage: 1110 is exactly the two's complement pattern for -2, and the raised final borrow is the machine's flag that the true result went below zero (for unsigned numbers, Bout = 1 simply means A < B). A ripple-borrow chain quietly produces two's complement answers whether you asked for them or not.
That is the perfect setup for the punchline taught in negative numbers and subtraction: hardware rarely builds this dedicated borrow chain at all. Since A - B = A + (NOT B) + 1, one XOR per bit turns the existing adder into a subtractor, and the two designs agree bit for bit; even the flags line up, since the adder's final carry-out is always the exact inverse of this chain's final borrow-out. A CPU that built both circuits would be paying twice for the same answers, so the ALU keeps one adder and a row of XORs, and the full subtractor remains the clearest way to *understand* what that trick is computing.
Try it
Trace A = 1, B = 1, Bin = 1 through the two-half-subtractor build: what are d1 and b1 from the first stage, D and b2 from the second, and the final Bout?
Build it in the lab ↗

Frequently asked

What is a full subtractor?

A full subtractor subtracts three bits, A - B - Bin (minuend, subtrahend, and the borrow coming in from the column below), producing a Difference D and a Borrow out Bout that passes any new debt to the next column. Chaining one per bit position subtracts multi-bit binary numbers.

What is the full subtractor truth table?

Eight rows, one per combination of A, B, Bin. The Difference is D = A XOR B XOR Bin (1 when an odd number of inputs are 1). The borrow Bout is 1 in exactly four rows: 0-0-1, 0-1-0, 0-1-1, and 1-1-1, that is, whenever B + Bin is more than A.

What is the difference between a full adder and a full subtractor?

Their first outputs are identical: the full adder's Sum and the full subtractor's Difference are both A XOR B XOR the third input. The second outputs mirror each other: the adder's carry is 1 when at least two of A, B, CIN are 1, while the subtractor's borrow is 1 when at least two of NOT A, B, Bin are 1. Inverting the minuend inside the second-output logic is the entire difference.

How do you build a full subtractor from half subtractors?

From two half subtractors and one OR gate, mirroring the full adder build. The first half subtractor computes A - B; the second subtracts Bin from that partial difference; the OR merges the two borrows into Bout. The two borrows are never both 1 at once, which is why a plain OR is safe.

Why do computers subtract with two's complement instead of a subtractor circuit?

Because one adder can then do both jobs. A - B = A + (NOT B) + 1, so a row of XOR gates (to conditionally invert B) plus a carry-in of 1 turns the existing adder into a subtractor, as taught in negative numbers and subtraction. A dedicated ripple-borrow subtractor produces bit-identical results but duplicates nearly all of the adder's hardware, so ALUs build the adder once and steer it.

Every lesson here builds toward one thing: a working CPU, from the transistor up.

Open the free lab →Or test yourself: the free placement exam takes 15 minutes →
Found this useful? Share itShare on X
Written by Taceddin SancakCreator of digiwleea. These lessons and the switch-level simulator every diagram runs on grew out of one goal: understand computers from the transistor up by building one.