Binary arithmetic follows the same principles as denary arithmetic, but with only two digits: 0 and 1. The addition rules are:
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 (carry) |
When adding three 1s (e.g., two 1 bits + a carry of 1): 1+1+1 = 1, carry 1.
Work from right to left, just like denary addition:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
|---|---|---|---|---|---|---|---|---|
| A | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| B | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| Result | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 1 |
00110101 (53) + 00011010 (26) = 01001111 (79) ✓
Overflow occurs when the result of an arithmetic operation is too large to be stored in the given number of bits.
Adding 11000000 (192) + 11000000 (192) = 110000000 which needs 9 bits. The 9th bit is lost, giving 10000000 = −128 in two's complement — clearly wrong!
Shifting binary digits left or right is equivalent to multiplying or dividing by powers of 2.
| Shift | Effect | Example (00001010 = 10) |
|---|---|---|
| Left shift 1 | × 2 | 00010100 = 20 |
| Left shift 2 | × 4 | 00101000 = 40 |
| Right shift 1 | ÷ 2 | 00000101 = 5 |
| Right shift 2 | ÷ 4 | 00000010 = 2 (remainder lost) |
8 Edexcel-style questions · AI-marked
| Term | Definition |
|---|
Timed exam-style test.