Unsigned binary subtraction computes where both (minuend) and (subtrahend) are unsigned binary numbers. Two main approaches: direct subtraction with borrow propagation, or “subtraction by addition” using complements — the latter lets you reuse adder hardware.
Direct subtraction with borrows
The grade-school approach, in binary. Subtract bit by bit from least significant to most significant, borrowing from the next column when needed.
If borrowing is required at the most significant position (an “end borrow”), it means , and the raw bit-pattern result is the 2’s complement of the true difference, with a missing minus sign.
Result interpretation
For -bit unsigned subtraction:
- No end borrow → . Result is correct as-is.
- End borrow → . Result is . To get the correct answer:
- Take the 2’s complement of the result (which gives ).
- Prepend a minus sign.
The "" expression is exactly the 2’s complement of — that’s why this works.
Subtraction by addition (using 2’s complement)
Modern hardware doesn’t build a separate subtractor. Instead, it converts subtraction into addition using complements, reusing the adder circuit.
Procedure
To compute :
- Compute the 2’s complement of .
- Add the result to .
- Interpret:
- If : discard the carry-out from the most significant bit. Result is the correct .
- If : take the 2’s complement of the result and prepend a minus sign.
Why this works
The 2’s complement of in -bit arithmetic is . Adding to :
For : the result is . Discarding the carry out of bit (the overflow) leaves . ✓
For : is negative. The result is positive but represents the negative of the answer in 2’s complement. Take the 2’s complement to recover , then negate.
Worked examples
Positive result: compute .
Take 2’s complement of : invert → , add 1 → .
Add: .
Discard the end carry (bit 7): . Result: . ✓ (Check: .)
Negative result: compute .
Take 2’s complement of : invert → , add 1 → .
Add: .
No end carry (bit 7 is part of the result). Take 2’s complement of : invert → , add 1 → . Prepend minus: . ✓
Subtraction by addition using 1’s complement
Slightly different procedure. Add the 1’s complement of (just bit-inverted, no ). If there’s a carry-out, perform an end-around carry — add the carry back to the result. If no carry-out, take the 1’s complement of the result and add a minus sign.
This is the older method, used in early computers. 2’s complement won out because it doesn’t need the end-around-carry step. See 1’s Complement and Radix Complement.
Why subtraction by addition
Hardware-economy reason: an adder is a complex circuit. Building a separate subtractor would double the silicon. Adding a row of XOR gates to optionally invert one operand (controlled by a “Sub” bit) lets one adder do both operations.
When Sub = 0: the XORs pass unchanged, , the adder computes .
When Sub = 1: the XORs invert , , the adder computes .
This adder/subtractor design is standard in CPUs. See 2’s Complement Arithmetic for the full picture.
For unsigned numbers and arithmetic, see Binary number system. For signed representations, see Signed binary number.