Number Systems
Revise Number Systems for Computer Science 0478 (O Level) — revision notes and instant AI marking. Free to start.
Number Systems
Computers only understand ON and OFF — every number, letter, colour and sound you'll ever see on a screen is really just patterns of 1s and 0s underneath. This guide shows you how to read, write, and convert between the three number systems computers and humans use to talk about that data: denary, binary, and hexadecimal.
Summary — What This Chapter Covers
- Why binary? Logic gates only have two states (on/off), so binary (1/0) is the natural fit for computer hardware.
- Three number systems: denary (base-10, for humans), binary (base-2, for computers), hexadecimal (base-16, a human-friendly shorthand for binary).
- Conversions: denary ↔ binary, denary ↔ hexadecimal, and binary ↔ hexadecimal (using nibbles).
- Why hex exists: it's shorter to write and easier for humans to read/copy accurately than long strings of binary — used in MAC addresses, colour codes, and URLs.
- Binary addition: adding two binary numbers together, including how carrying works and what happens when you run out of bits (overflow).
- Binary shifts: moving bits left or right to multiply or divide by powers of 2.
- Two's complement: how computers represent negative numbers using only 1s and 0s.
1. Why Computers Use Binary
The core reason
Inside every computer, data is processed using logic gates — tiny electronic switches that can only be in one of two states: on or off, high voltage or low voltage, current flowing or not flowing. There's no "half on."
Binary is the number system that's made up of exactly two digits — 1 and 0. This lines up perfectly: 1 can represent "on" and 0 can represent "off." Because of this natural match, all data — text, images, sound, video — must be converted into binary before a computer can understand and process it.
Where you can actually see this happening
Secondary storage devices physically store binary using two-state properties:
- Magnetic hard drives use North and South magnetic polarity to represent a 1 or a 0.
- Optical disks (CDs/DVDs) use a laser: light hitting a flat area (land) is read as a 1, and light hitting a bump (pit) is read as a 0.
Explain why computers process data in binary format. [2 marks]
2. The Three Number Systems
2.1 Denary (base-10)
This is the number system you already use every day — made up of 10 digits (0–9). Each digit's position (column) has a weight which is 10 raised to a power. Starting from the right: 10⁰ = 1s, 10¹ = 10s, 10² = 100s, 10³ = 1000s, and so on. Every time you move one column to the left, the value is multiplied by 10.
| Column heading (using 10ˣ) | 1000 (10³) | 100 (10²) | 10 (10¹) | 1 (10⁰) |
|---|---|---|---|---|
| Digit | 3 | 2 | 6 | 8 |
Reading this: (3×1000) + (2×100) + (6×10) + (8×1) = 3268. To represent bigger numbers, you simply add more digits (more columns) to the left.
2.2 Binary (base-2)
Made up of only two digits (0 and 1). Just like denary, each column has a weight — but this time it's 2 raised to a power. From the right: 2⁰ = 1, 2¹ = 2, 2² = 4, 2³ = 8... Each new column to the left doubles the previous column's value (rather than ×10 like denary).
| Column heading (using 2ˣ) | 8 (2³) | 4 (2²) | 2 (2¹) | 1 (2⁰) |
|---|---|---|---|---|
| Digit | 1 | 1 | 0 | 0 |
Reading this: binary 1100 = (1×8) + (1×4) + (0×2) + (0×1) = 12 in denary.
The full set of column headings you need for IGCSE (up to 16-bit, Cambridge's limit) is:
2.3 Hexadecimal (base-16)
Made up of 16 digits — the numbers 0–9, plus the letters A–F standing in for 10–15 (since we've run out of single digits after 9!). Each column's weight is 16 raised to a power: 16⁰ = 1s, 16¹ = 16s. For IGCSE, you only need to work with 2-digit hexadecimal values.
| Denary | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Hex | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
Example: hex 13 = (1×16) + (3×1) = 19 in denary.
| Denary | Binary | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
3. Converting Between Binary & Denary
3.1 Denary → Binary
Method:
- Write out the binary number line (column headings), starting with the first heading larger than your denary number, then every heading to the right of it down to 1.
- Start at the leftmost empty column. Ask "how many times does this heading fit into my remaining number?" — the answer is always 0 or 1 for binary.
- Write down the remainder, move to the next column, and repeat until every column has a value.
Worked example: Convert denary 45 to binary.
The first heading bigger than 45 is 64, so our number line starts at 32:
| 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 | 1 |
32 fits into 45 once, remainder 13. 16 doesn't fit into 13, so 0. 8 fits into 13 once, remainder 5. 4 fits into 5 once, remainder 1. 2 doesn't fit into 1, so 0. 1 fits into 1 once, remainder 0.
Result: 45 = 101101 in binary (6 bits).
Convert denary 3059 to binary.
3.2 Binary → Denary
Method: Write out the column headings for the number of bits given (from right to left), place each binary digit under its heading, then add together every column heading that has a 1 underneath it.
Worked example: Convert binary 01100011 (8 bits) to denary.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 |
(1×64) + (1×32) + (1×2) + (1×1) = 99
Convert binary 01110001110100 (14 bits) to denary.
4. Converting Between Hexadecimal & Denary
4.1 Denary → Hexadecimal
Method 1 — via binary (safest, no calculator needed):
- Convert the denary number to 8-bit binary.
- Split the 8 bits into two nibbles (groups of 4).
- Convert each nibble to its denary value, then to its hex digit.
Example: Convert denary 28 to hex.
28 in binary = 0001 1100. First nibble 0001 = 1. Second nibble 1100 = 12 = C. So 28 = 1C in hex.
Method 2 — divide by 16:
Divide the denary number by 16. The whole number of times it goes in becomes hex digit 1; the remainder becomes hex digit 2.
Example: Convert 163 to hex. 163 ÷ 16 = 10 remainder 3. Digit 1 = 10 = A. Digit 2 = 3. So 163 = A3 in hex.
4.2 Hexadecimal → Denary
Method 1 — via binary: convert each hex digit to its 4-bit nibble, join the nibbles into a byte, then convert binary → denary as normal.
Example: Convert hex B9 to denary.
B = 1011, 9 = 1001 → joined: 10111001 → (1×128)+(1×32)+(1×16)+(1×8)+(1×1) = 185
Method 2 — multiply by 16: multiply the first hex digit's denary value by 16, then add the second digit's denary value.
Example: Convert hex 79 to denary. 7 × 16 = 112, then 112 + 9 = 121.
Convert hex 4E to denary using both methods, and check your answers agree.
5. Converting Between Hexadecimal & Binary
This is the conversion you'll use most often, because it relies purely on the nibble rule — one hex digit = 4 bits — with no denary maths required at all.
5.1 Binary → Hexadecimal
- Split the binary number into groups of 4 bits (nibbles), starting from the right.
- Convert each nibble to its denary/hex value using the table.
- Join the two hex digits together.
Example: Convert binary 10110111 to hex.
| 8 | 4 | 2 | 1 | 8 | 4 | 2 | 1 | |
|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 | 1 | 1 | 1 |
First nibble = 8+2+1 = 11 = B. Second nibble = 4+2+1 = 7 = 7. Result: B7.
5.2 Hexadecimal → Binary
- Split the hex digits apart.
- Convert each digit to its 4-bit binary nibble.
- Join the nibbles together to form the full binary number.
Example: Convert hex 5F to binary.
5 = 0101, F = 1111 → joined: 01011111
Convert hex 26 to binary, and then convert binary 00111001 to hex. (Check they don't accidentally match!)
6. Why Do We Even Bother With Hexadecimal?
You might be wondering — if computers only understand binary, why do we need hexadecimal at all? The answer is entirely about humans, not computers.
Think about it concretely: a MAC address needs 48 bits of binary to represent. Would you rather read/copy this...
10101010:10111011:11001100:11011101:11101110:11111111
...or this equivalent, written in hex?
AA:BB:CC:DD:EE:FF
Same information, but the hex version is a quarter of the length and far less error-prone to copy by hand.
Where hexadecimal is actually used
- MAC addresses: a unique network hardware identifier — 12 hex digits (48 bits in binary), e.g. 2C-F0-7C-A7-98.
- Colour codes: web/screen colours use 6 hex digits (24 bits in binary) — 2 digits each for Red, Green, Blue. E.g. #66FF33 is a shade of green: 01100110 : 11111111 : 00110011.
- URLs: a URL can only officially contain standard letters (a-z, A-Z), numbers (0-9), and a small set of special symbols. If a URL needs a character outside this set, it gets converted into a hexadecimal code, prefixed with a % sign.
A student says "hexadecimal is used because it's shorter than binary." Explain why this answer would likely lose a mark, and rewrite it to gain full marks.
7. Binary Addition
Binary addition works just like the column addition you learned in primary school for denary numbers — except there are only two digits, so the "carrying" rules are simpler but happen much more often.
The 5 golden rules
| Sum | Result | Working |
|---|---|---|
| 0 + 0 | 0 | no carry |
| 0 + 1 | 1 | no carry |
| 1 + 0 | 1 | no carry |
| 1 + 1 | 10 | write 0, carry 1 |
| 1 + 1 + 1 | 11 | write 1, carry 1 |
Worked example: Add binary 00011001 (25) and 10001001 (137).
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| carries: 1 in the 2s column, 1 in the 32s column, 1 in the 16s column | |||||||
| 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 |
Result: 10100010 = 162 in denary. Check: 25 + 137 = 162 ✓
Overflow errors
An overflow error happens when the result of an addition needs more bits than you have available. For example, adding 11111111 (255) + 00000001 (1) in 8 bits would need a 9th bit to store the answer (256) — that 9th bit gets lost, causing an overflow error and an incorrect result.
Add binary 1001 (9) and 0100 (4), showing your carries. Does an overflow occur?
8. Binary Shifts
A logical binary shift is how computers perform quick multiplication and division on non-negative numbers — by physically sliding every bit left or right along the row.
A right shift of 1 place divides the number by 2 (÷2).
Shifting 2 places = ×4 or ÷4. Shifting 3 places = ×8 or ÷8 — and so on.
Left shift example
Shift binary 00101000 (denary 40) left by 1 place. Every bit moves one column left; the empty column on the right (the 1s column) is filled with a 0.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 0 | 0 | 0 | = 40 | |
| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | = 80 |
40 doubled to 80. ✓
Right shift example
Shift binary 00101000 (denary 40) right by 1 place. Every bit moves one column right; the bit that falls off the right-hand edge (the LSB) is lost, and a 0 fills the empty column on the left.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 1 | 0 | 0 | = 40 | |
| 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | = 20 |
40 halved to 20. ✓
Overflow in shifts
Overflow in a left shift happens when a 1 is pushed out of the leftmost column (MSB) and lost — this changes the value's meaning drastically, since important high-value data is discarded. You generally only need to spot overflow on left shifts, not right shifts, at this level.
Shift binary 00011100 (denary 28) left by 2 places. What's the new denary value? Does overflow occur?
9. Two's Complement
So far, every binary number we've used has been positive (unsigned). But computers need to represent negative numbers too — and they can't use a "minus sign" because that's not a 1 or a 0! The solution is two's complement: a clever system for representing signed (positive AND negative) numbers using only binary digits.
Example: What does 11111111 represent?
| −128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
Add up every column with a 1: −128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = −1. So 11111111 represents −1 in two's complement.
Converting a negative number TO two's complement
The reliable method:
- Write out the positive version of the number in normal binary.
- Starting from the rightmost bit, copy every digit across unchanged up to and including the first 1 you encounter.
- For every digit after that first 1 (moving left), invert it — flip every 0 to a 1 and every 1 to a 0.
Worked example: Represent −76 in 8-bit two's complement.
Step 1: Positive 76 in binary = 01001100
| −128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
Step 2: Copy from the right up to and including the first 1 — that's the rightmost 1 in the 4s column, plus the two 0s to its right (2s, 1s columns): 1 0 0 stays unchanged.
Step 3: Invert everything to the left of that: 0 1 0 0 → 1 0 1 1
| −128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 |
Check: −128 + 32 + 16 + 4 = −76 ✓
Result: −76 = 10110100 in two's complement.
Represent −20 in 8-bit two's complement.
What to Memorise
Concepts Checklist
Exam Tips
- 3. Converting Between Binary & Denary
- 4. Converting Between Hexadecimal & Denary
- 5. Converting Between Hexadecimal & Binary
Read the full Number Systems notes free
That's the preview — create a free account to read the rest, plus flashcards and practice questions with instant AI marking. No credit card.
Unlock the full notes free →