This page is the exhaustive drill room for the Subtractors parent note. We are not learning new theory here — we are stress-testing the formulas against every kind of input the topic can hand you , so that when an exam or a real circuit throws an edge case, you have already seen it.
Two formulas carry this whole page. Keep them in view:
A reminder on the three symbols, because we will use them on every line:
A = the top bit (the number we subtract from ). Picture it as candies in the upper jar.
B = the bottom bit (the amount we take away ).
⊕ = XOR , which outputs 1 when the inputs disagree (see XOR-Gate ).
A ˉ = "NOT A ", i.e. flip A : 0 ˉ = 1 , 1 ˉ = 0 .
B o u t = borrow-out , the "I owe the next-higher column one" note.
Every situation subtraction can throw falls into one of these cells . The worked examples below are each tagged with the cell they cover, and together they hit all of them.
Cell
What makes it special
Covered by
C1 — HS, no borrow
top ≥ bottom, single column
Ex 1
C2 — HS, borrow forced
A = 0 , B = 1 : the "boss is broke" case
Ex 2
C3 — FS, all zero (degenerate)
every input 0 : does anything happen?
Ex 3
C4 — FS, double-borrow (most negative)
A = 0 , B = 1 , B in = 1 → − 2
Ex 4
C5 — FS, borrow cancels
inputs conspire so no borrow leaves
Ex 5
C6 — Multi-bit, A > B (positive result)
ripple chain, final borrow = 0
Ex 6
C7 — Multi-bit, A < B (negative / wraps)
final borrow = 1 , what it means
Ex 7
C8 — Subtraction via 2's-complement adder
the real-CPU method
Ex 8
C9 — Word problem (real world)
a bank balance / countdown
Ex 9
C10 — Exam twist (limiting / all-ones)
A = B largest value, borrow behaviour
Ex 10
Worked example Ex 1 — Cell C1: half subtractor, no borrow (
A = 1 , B = 0 )
Compute D and B o u t for a single column, top bit 1 , bottom bit 0 , no borrow-in.
Forecast: 1 − 0 = 1 . The top jar already has enough, so we should keep 1 and owe nobody. Guess D = 1 , B o u t = 0 .
D = A ⊕ B = 1 ⊕ 0 . Why this step? XOR asks "do the bits disagree?" They do (1 vs 0 ), so D = 1 .
B o u t = A ˉ B = 1 ˉ ⋅ 0 = 0 ⋅ 0 = 0 . Why this step? Borrow needs the top bit broke (A ˉ = 1 ) — but here 1 ˉ = 0 , so borrow is impossible.
Verify: arithmetic 1 − 0 = 1 , no negative, so D = 1 and B o u t = 0 . ✓ Matches forecast.
Worked example Ex 2 — Cell C2: half subtractor, borrow forced (
A = 0 , B = 1 )
The only HS row that borrows. Top 0 , bottom 1 .
Forecast: 0 − 1 can't be done in an unsigned column — you must run upstairs. Guess D = 1 , B o u t = 1 .
Borrow 2 from above: 0 + 2 − 1 = 1 , so the leftover is 1 . Why this step? In binary the "big bundle" you borrow is worth 2 (one place value up).
D = 0 ⊕ 1 = 1 (bits disagree). Why this step? confirms the leftover algebraically.
B o u t = 0 ˉ ⋅ 1 = 1 ⋅ 1 = 1 . Why this step? top is broke (0 ˉ = 1 ) AND bottom is 1 , both conditions of a borrow are met.
Verify: we did take 2 from upstairs, so that column owes 1 → B o u t = 1 ; leftover = 1 → D = 1 . ✓
Common mistake The classic C2 trap
Students copy the adder carry A B here: A ⋅ B = 0 ⋅ 1 = 0 — wrong . Borrow is A ˉ B , not A B . Row C2 is the row that catches this every time.
Worked example Ex 3 — Cell C3: full subtractor, all-zero degenerate (
A = 0 , B = 0 , B in = 0 )
Nothing to subtract, nothing owed. Does the circuit sit still?
Forecast: 0 − 0 − 0 = 0 , no borrow. Guess D = 0 , B o u t = 0 .
D = 0 ⊕ 0 ⊕ 0 = 0 . Why this step? XOR counts 1 's — there are zero 1 's (even), so output 0 .
B o u t = 0 ˉ ⋅ 0 + 0 ˉ ⋅ 0 + 0 ⋅ 0 = 0 + 0 + 0 = 0 . Why this step? every product needs a 1 from B or B in ; all are 0 .
Verify: the truly empty case is stable — outputs are 0 . ✓ This is the "identity" row every full subtractor must handle.
Worked example Ex 4 — Cell C4: full subtractor, double borrow / most negative (
A = 0 , B = 1 , B in = 1 )
The deepest deficit: nothing on top, subtract 1 and already owe 1 .
Forecast: 0 − 1 − 1 = − 2 . That's the most negative a single FS column reaches. Guess we borrow and leftover is 0 .
Borrow 2 : 0 + 2 − 1 − 1 = 0 , leftover D = 0 . Why this step? even one big bundle (value 2 ) exactly covers the − 2 , leaving nothing.
D = 0 ⊕ 1 ⊕ 1 = 0 . Why this step? two 1 's = even parity → D = 0 , confirms leftover.
B o u t = 0 ˉ ⋅ 1 + 0 ˉ ⋅ 1 + 1 ⋅ 1 = 1 + 1 + 1 = 1 . Why this step? OR of the terms: any single 1 makes borrow 1 . We definitely owe upstairs.
Verify: − 2 absolutely needs a borrow (B o u t = 1 ); after borrowing 2 the column is empty (D = 0 ). ✓
Worked example Ex 5 — Cell C5: full subtractor, borrow cancels (
A = 1 , B = 0 , B in = 1 )
A borrow comes in, but the top bit is rich enough to absorb it — no borrow leaves.
Forecast: 1 − 0 − 1 = 0 , and since top could cover it, guess no outgoing borrow: D = 0 , B o u t = 0 .
D = 1 ⊕ 0 ⊕ 1 = 0 . Why this step? two 1 's (from A and B in ), even parity → 0 .
B o u t = 1 ˉ ⋅ 0 + 1 ˉ ⋅ 1 + 0 ⋅ 1 = 0 + 0 + 0 = 0 . Why this step? every term contains 1 ˉ = 0 or a 0 factor — the top bit being 1 kills all borrow terms except B B in , and B = 0 kills that too.
Verify: 1 − 0 − 1 = 0 is non-negative, so no outgoing borrow. ✓ This proves an incoming borrow does not force an outgoing one.
Now we cascade full subtractors, LSB → MSB, feeding each column's B o u t into the next as B in . This is a ripple-borrow chain . See the wiring below.
Worked example Ex 6 — Cell C6: multi-bit
A > B , positive result (5 − 2 , 3-bit)
5 = 101 , 2 = 010 . Chain three FS, starting B in , 0 = 0 .
Forecast: 5 − 2 = 3 = 011 , and since 5 > 2 the answer is non-negative → final borrow should be 0 .
bit0: A = 1 , B = 0 , B in = 0 ⇒ D 0 = 1 ⊕ 0 ⊕ 0 = 1 , B o u t = 1 ˉ ⋅ 0 + 1 ˉ ⋅ 0 + 0 ⋅ 0 = 0 . Why this step? 1 − 0 = 1 , top rich, no borrow up.
bit1: A = 0 , B = 1 , B in = 0 ⇒ D 1 = 0 ⊕ 1 ⊕ 0 = 1 , B o u t = 0 ˉ ⋅ 1 = 1 . Why this step? 0 − 1 forces a borrow to bit2.
bit2: A = 1 , B = 0 , B in = 1 ⇒ D 2 = 1 ⊕ 0 ⊕ 1 = 0 , B o u t = 1 ˉ ⋅ 0 + 1 ˉ ⋅ 1 + 0 ⋅ 1 = 0 . Why this step? 1 − 0 − 1 = 0 , the top covers the incoming borrow (this is exactly Cell C5!).
Verify: result = D 2 D 1 D 0 = 011 = 3 , final borrow 0 . And 5 − 2 = 3 . ✓
Worked example Ex 7 — Cell C7: multi-bit
A < B , result wraps (2 − 5 , 3-bit)
2 = 010 , 5 = 101 . What happens when the top number is smaller ?
Forecast: 2 − 5 = − 3 , which is negative. In unsigned hardware a negative can't be stored, so we expect the final borrow = 1 (a flag saying "answer went negative") and the bits to show 2 3 + ( 2 − 5 ) = 5 = 101 .
bit0: A = 0 , B = 1 , B in = 0 ⇒ D 0 = 1 , B o u t = 0 ˉ ⋅ 1 = 1 . Why this step? 0 − 1 borrows.
bit1: A = 1 , B = 0 , B in = 1 ⇒ D 1 = 1 ⊕ 0 ⊕ 1 = 0 , B o u t = 1 ˉ ⋅ 0 + 1 ˉ ⋅ 1 + 0 ⋅ 1 = 0 . Why this step? top 1 absorbs the incoming borrow, none leaves.
bit2: A = 0 , B = 1 , B in = 0 ⇒ D 2 = 1 , B o u t = 0 ˉ ⋅ 1 = 1 . Why this step? 0 − 1 borrows again — this is the borrow that leaves the whole 3-bit block.
Verify: result bits = 101 = 5 , and 5 = 8 − 3 = 2 3 + ( 2 − 5 ) . Final borrow = 1 correctly flags "A < B , true answer is negative". ✓
Reading the flag: the final B o u t = 1 is the hardware's way of saying "I had to borrow past the last column — the real result is negative."
Worked example Ex 8 — Cell C8: compute
6 − 3 with an ADDER, not a subtractor
Real CPUs (see Adder-Subtractor-Circuit ) never build a dedicated subtractor. They compute A + B ˉ + 1 using an adder . Let's do 6 − 3 this way with n = 3 bits. 6 = 110 , 3 = 011 .
Forecast: 6 − 3 = 3 = 011 . Using A + B ˉ + 1 : invert B , add 1 , add to A , throw away the final carry. Guess the low 3 bits come out 011 and a carry-out of 1 appears.
Invert B : B ˉ = 011 = 100 . Why this step? 2's complement of B is B ˉ + 1 ; the invert is done by XOR gates with the control line set to 1 .
Set carry-in = 1 (this supplies the "+ 1 "). Why this step? without the + 1 you'd have only 1's-complement — off by one.
Add: A + B ˉ + 1 = 110 + 100 + 1 . Compute 110 + 100 = 1010 (that's 6 + 4 = 10 ), then + 1 = 1011 = 11 . Why this step? this is A + ( 2 n − B ) = 2 n + ( A − B ) = 8 + 3 = 11 .
Discard the top carry (the 2 n = 8 bit): keep low 3 bits of 1011 → 011 = 3 . Why this step? the 2 3 is exactly the carry-out you throw away, leaving A − B .
Verify: low bits = 011 = 3 = 6 − 3 , and carry-out = 1 (meaning A ≥ B , result non-negative — note the carry flag is the opposite convention to the borrow flag). ✓
Common mistake Ex 8's hidden trap — the
+ 1
"Invert B " alone gives A + B ˉ = A − B − 1 . You are one short . The carry-in = 1 is not optional decoration; it is the + 1 that turns 1's-complement into 2's-complement.
Worked example Ex 9 — Cell C9: real-world word problem (a countdown)
A gate counter shows 4 people inside. 6 people try to leave. Using 3-bit subtraction, what does the counter compute, and what does the borrow flag tell the guard?
Forecast: 4 − 6 = − 2 : more people left than were inside (data error!). We expect a final borrow = 1 warning the guard, and wrapped bits 2 3 − 2 = 6 = 110 .
A = 4 = 100 , B = 6 = 110 . Why this step? encode the real quantities in binary.
bit0: 0 − 0 − 0 ⇒ D 0 = 0 , B o u t = 0 . bit1: 0 − 1 − 0 ⇒ D 1 = 1 , B o u t = 1 (0 − 1 borrows). bit2: 1 − 1 − 1 = − 1 ⇒ D 2 = 1 ⊕ 1 ⊕ 1 = 1 , B o u t = 1 ˉ ⋅ 1 + 1 ˉ ⋅ 1 + 1 ⋅ 1 = 0 + 0 + 1 = 1 . Why this step? ripple the borrow through all three columns.
Read result: D 2 D 1 D 0 = 110 = 6 , final borrow = 1 . Why this step? the borrow-out is the guard's "impossible — more left than present" alarm.
Verify: 2 3 + ( 4 − 6 ) = 8 − 2 = 6 = 110 ✓, and final borrow = 1 correctly flags the negative (nonsensical) result. ✓ The guard learns the count is corrupted.
Worked example Ex 10 — Cell C10: exam twist, limiting all-ones case (
A = B = 7 , 3-bit)
"The largest 3-bit number minus itself — does any borrow ever leave?" 7 = 111 .
Forecast: 7 − 7 = 0 . Equal numbers → zero difference, and intuitively no net borrow. Guess all D i = 0 , final borrow 0 .
bit0: A = 1 , B = 1 , B in = 0 ⇒ D 0 = 1 ⊕ 1 = 0 , B o u t = 1 ˉ ⋅ 1 = 0 . Why this step? equal bits, top not broke, no borrow.
bit1: A = 1 , B = 1 , B in = 0 ⇒ D 1 = 0 , B o u t = 0 . Why this step? identical to bit0.
bit2: A = 1 , B = 1 , B in = 0 ⇒ D 2 = 0 , B o u t = 0 . Why this step? identical again — no borrow chain ever starts.
Verify: result = 000 = 0 = 7 − 7 , final borrow = 0 (result non-negative). ✓ The limiting all-ones case is boring precisely because equal bits never borrow.
Recall Cover-check: can you place each into its cell?
Ex 2 hits which cell? ::: C2 — HS borrow forced (A = 0 , B = 1 )
Which example proves an incoming borrow need NOT cause an outgoing one? ::: Ex 5 (Cell C5), A = 1 , B = 0 , B in = 1
Which two examples show the final borrow flag = "result is negative"? ::: Ex 7 (2 − 5 ) and Ex 9 (the countdown)
In Ex 8, what supplies the "+1" of 2's complement? ::: The adder's carry-in set to 1
Subtractors — the parent theory these examples exercise.
Adders — Ex 8 reuses an adder to subtract.
Twos-Complement-Representation — the A + B ˉ + 1 trick in Ex 8.
Adder-Subtractor-Circuit — one control line does both, per Ex 8.
XOR-Gate — every D computation is a parity/XOR.
Ripple-Carry-Chains — the cascade in Ex 6, 7, 9, 10.