Binary addition works like decimal addition, but with only two digits. The rules are:
| Calculation | Binary result | Write down | Carry |
|---|---|---|---|
| 0 + 0 | 0 | 0 | 0 |
| 0 + 1 | 1 | 1 | 0 |
| 1 + 0 | 1 | 1 | 0 |
| 1 + 1 | 10 | 0 | 1 |
| 1 + 1 + 1 (with carry) | 11 | 1 | 1 |
Add 00110101₂ (53) and 00101110₂ (46):
Result: 01100011₂ = 99₁₀ ✓ (53 + 46 = 99)
Add 00010111₂ (23) and 00001011₂ (11):
Result: 00100010₂ = 34₁₀ ✓ (23 + 11 = 34)
Overflow occurs when the result of a binary calculation is too large to fit in the number of bits available. An 8-bit register can store a maximum of 11111111₂ = 255₁₀.
carry: 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 (255₁₀)
+ 0 0 0 0 0 0 0 1 (1₁₀)
1 0 0 0 0 0 0 0 0 ← 9 bits! The leading 1 is lost.
Stored as: 0 0 0 0 0 0 0 0 = 0₁₀ — WRONG!
The carry out from the 8th bit position is discarded, giving an incorrect result. This is called a carry overflow.
Overflow causes programs to produce incorrect results silently — the calculation appears to succeed, but the stored value is wrong. This has caused real-world disasters, including spacecraft failures from integer overflow errors.
8 questions · 20 marks
| Term | Definition |
|---|
Timed exam conditions.