Binary Arithmetic

intermediate30 min

Learning objectives

  • Perform binary addition and subtraction
  • Recognise overflow
  • Explain why overflow occurs
  • Solve binary arithmetic problems accurately

Learn

AQA 4.5.2 — Binary arithmetic

Retrieval: the Binary Number System lesson converted whole numbers between denary and binary. This lesson asks: once two numbers are already in binary, how do you actually add or subtract them, directly in base 2, without converting back to denary first?

Key vocabulary

  • Bit — a single binary digit, 0 or 1.
  • Carry — an extra 1 passed to the next column left, produced when a column's total is too large to fit in a single bit.
  • Register / word length — the fixed number of bits a computer allocates to store one value (e.g. 8 bits). A real processor cannot suddenly grow an extra bit mid-calculation.
  • Overflow — the error condition where a calculation's true result needs more bits than the register has available, so the extra bit is lost and the stored result becomes wrong.

Understand — why binary addition needs carrying so much sooner

In denary (base 10), a column carries once its total reaches 10. In binary (base 2), a column only has two possible digits, so it carries once its total reaches just 2 — far more often. The mechanism is identical to the denary addition you already know; only the carry threshold changes.

See it — binary addition, column by column

Adding 0111 (7) and 0011 (3), worked one column at a time from the right, exactly like column addition on paper:

  carry:   1 1 1
             0 1 1 1
           + 0 0 1 1
           ---------
             1 0 1 0

Column by column: rightmost column 1 + 1 = 10 in binary — write 0, carry 1. Next column 1 + 1 + (carry 1) = 11 — write 1, carry 1. Next column 1 + 0 + (carry 1) = 10 — write 0, carry 1. Leftmost column 0 + 0 + (carry 1) = 1 — write 1. Result: 1010, which is 10 in denary — matching 7 + 3 = 10 exactly.

Calculate it — three worked examples, increasing in difficulty

Example 1 (no carrying): 0001 + 0010 → each column totals at most 1, so no carry is ever needed → 0011 (1 + 2 = 3). ✓

Example 2 (a single carry): 0101 + 0011 (5 + 3): rightmost column 1 + 1 = 10 → write 0, carry 1. Next 0 + 1 + 1 = 10 → write 0, carry 1. Next 1 + 0 + 1 = 10 → write 0, carry 1. Leftmost 0 + 0 + 1 = 1 → write 1. Result: 1000 = 8. ✓ (5 + 3 = 8)

Example 3 (overflow in a 4-bit register): 1111 + 0001 (15 + 1, using only 4 bits): rightmost 1 + 1 = 10 → write 0, carry 1, and this carrying cascades all the way through every column, producing 10000 — but that's 5 bits, and this register only holds 4. The leading 1 is lost, leaving the stored result as 0000 (0) — silently and incorrectly, instead of the true answer, 16.

Explain — why overflow happens

A computer's registers have a fixed number of bits, decided by the hardware, not by how large a particular calculation happens to be. When a true result needs one more bit than the register provides, that extra bit simply has nowhere to go and is discarded — the stored value becomes wrong, without any visible error message at the point it happens. This is precisely why real programming languages define maximum integer sizes, and why some categories of bugs (a counter silently wrapping back to zero) trace directly back to this exact mechanism.

Binary subtraction

Binary subtraction follows the same column-by-column logic as denary subtraction, borrowing from the next column left when needed: 0101 - 0011 (5 - 3) → rightmost column 1 - 1 = 0. Next 0 - 1: not enough, so borrow from the next column, making it 10 - 1 = 1, and reduce the borrowed-from column by one. Working through fully gives 0010 = 2, matching 5 - 3 = 2. ✓

Check your understanding

Work through these by hand, showing your carries or borrows explicitly, before checking: 0110 + 0101 (6 + 5); 1000 - 0011 (8 − 3); and 1110 + 0010 using only 4 bits (does this overflow?).

(0110 + 0101 = 1011 = 11. 1000 - 0011 = 0101 = 5. 1110 + 0010 = 10000, which needs 5 bits - in a 4-bit register this overflows, storing 0000 instead of the true result 16.)

Challenge

Write out, column by column with all carries shown, the addition 1011 + 1101 in an 8-bit register (padding both numbers with leading zeros to 8 bits first). Does this particular addition overflow an 8-bit register? Justify your answer using the actual bit-length of the true result.

Looking ahead: the next lesson (Hexadecimal) returns to representing binary values compactly rather than calculating with them — but the same fixed-width thinking from this lesson (a nibble is exactly 4 bits, no more, no less) reappears there directly.

Practise

Apply what you've just learned in the Coding Lab.

Open Coding Lab

Test yourself

Check your understanding with exam-style questions.

Go to Exam Practice
Log in to track this lesson on your progress dashboard.
Log in