Year 8 Digital Technologies · Data and Information · 9m read
Data Representation — Hexadecimal and Colour
Ever wondered why a website designer types something like #FF5733 to pick a specific shade of red? That's hexadecimal—a clever number system that computers use to represent colours more efficiently than decimal or binary. You'll learn how to convert between these three number systems and understand how your screen mixes just three colour channels (red, green, blue) to create millions of hues. Mastering this connects you directly to how digital design works and gives you insight into why data is organised the way it is in computing.
Learning objective: Convert between binary, decimal and hexadecimal, and explain how colour is represented digitally.
By the end of this lesson you can:
- I convert between binary, decimal and hexadecimal.
- I explain the RGB colour model and how hex codes represent colours.
- I explain file size units from bits to terabytes.
Hex colours are paint recipes. #FF8800 means "full red, half green, no blue". Two hex digits per colour channel mix the exact shade.
Hexadecimal and digital colour
HEXADECIMAL (base-16):
16 symbols: 0–9 and A–F (A=10, B=11, C=12, D=13, E=14, F=15).
Used because: one hex digit = exactly 4 binary digits (a "nibble").
Two hex digits = 1 byte (8 bits). Compact way to represent binary.
HEX ↔ DECIMAL:
Position values (right to left): 16⁰=1, 16¹=16, 16²=256.
3F (hex) = 3×16 + 15×1 = 48 + 15 = 63 (decimal).
Decimal → hex: divide by 16, track remainders.
200 ÷ 16 = 12 remainder 8. 12 = C. So 200₁₀ = C8₁₆.
HEX ↔ BINARY: convert directly 4 bits at a time.
1111 = F. 0101 = 5. So 1111 0101 = F5 (hex).
RGB COLOUR MODEL:
All digital colours described using Red, Green, Blue components.
Each component: 0–255 (one byte each). Stored as 8 bits per channel.
Total: 3 × 8 = 24 bits per pixel = "24-bit true colour" = 16.7 million possible colours.
HEX COLOUR CODES (e.g. in web design):
#RRGGBB — two hex digits for each channel.
#FF0000 = pure red (R=255, G=0, B=0).
#00FF00 = pure green.
#0000FF = pure blue.
#FFFFFF = white (all max). #000000 = black (all zero).
#A30C8B = R=163, G=12, B=139 (a purple shade).
FILE SIZE UNITS:
1 bit: 0 or 1.
8 bits = 1 BYTE.
1024 bytes = 1 KILOBYTE (KB).
1024 KB = 1 MEGABYTE (MB).
1024 MB = 1 GIGABYTE (GB).
1024 GB = 1 TERABYTE (TB).
Approx sizes: email (~10 KB), song (~5 MB), film (~2 GB), backup drive (1–8 TB).
Hexadecimal conversion rules
- Hex to binary: 4 bits per digit: Each hex digit maps to exactly 4 binary digits. A=1010, F=1111. F3 = 1111 0011.
- RGB values 0–255: Each RGB channel is ONE BYTE (8 bits, values 0–255). Two hex digits cover 0–255 exactly (FF hex = 255 decimal).
- Colour mixing: High R + high G = yellow. High R + high B = magenta. High G + high B = cyan. All high = white. All zero = black.
Quick reference
| Hex | Decimal | Binary |
|---|---|---|
| 0 | 0 | 0000 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| F | 15 | 1111 |
| FF | 255 | 11111111 |
| #FF0000 | Red | RGB(255, 0, 0) |
Worked example (Medium)
Convert hex colour #4B2A9F to RGB decimal values.
- Split hex. R = 4B, G = 2A, B = 9F.
- Convert each. R: 4×16 + 11 = 64+11 = 75. G: 2×16 + 10 = 32+10 = 42. B: 9×16 + 15 = 144+15 = 159.
- RGB. R=75, G=42, B=159. This is a medium blue-purple.
Answer: R=75, G=42, B=159 (a blue-purple hue).
Worked example (Hard)
An image is 1920 × 1080 pixels using 24-bit true colour. Calculate the uncompressed file size in megabytes.
- Total pixels. 1920 × 1080 = 2 073 600 pixels.
- Bits per pixel. 24-bit colour = 3 channels × 8 bits = 24 bits per pixel.
- Total bits. 2 073 600 × 24 = 49 766 400 bits.
- Convert to megabytes. 49 766 400 ÷ 8 = 6 220 800 bytes. 6 220 800 ÷ 1024 = 6 075 KB. 6 075 ÷ 1024 ≈ 5.93 MB.
Answer: Approximately 5.93 MB uncompressed. This is why image compression (JPEG, PNG) is essential — a JPEG of this image might be only 0.5–2 MB.
Common mistakes
- Using 1000 instead of 1024 for byte conversions Digital storage uses binary (base-2), so 1 KB = 1024 bytes, not 1000. Using 1000 gives inaccurate file size calculations. Fix: Always use 1024 for byte conversions: 1 KB = 1024 B, 1 MB = 1024 KB, 1 GB = 1024 MB.
- Forgetting that A–F represent 10–15 in hex Students write hex digits A–F but forget to convert them to their decimal equivalents (A=10, B=11, etc.) when calculating. Fix: Write out the mapping before any conversion: A=10, B=11, C=12, D=13, E=14, F=15.
- Confusing bits and bytes A bit is a single 0 or 1. A byte is 8 bits. Mixing them up causes file size calculations to be off by a factor of 8. Fix: Remember: 8 bits = 1 byte. Internet speeds are often in bits/second; file sizes are in bytes. Divide bits by 8 to get bytes.
Why hexadecimal became the standard for colour codes
Hexadecimal wasn't chosen for colour codes by accident — it's a direct consequence of how computers store data. Computers work in binary (base-2), but binary is extremely tedious for humans: the colour white is 111111111111111111111111 in binary. Decimal is human-friendly but doesn't align neatly with binary.
Hexadecimal (base-16) is the sweet spot because each hex digit maps to exactly 4 binary digits (a "nibble"). Two hex digits = 8 bits = 1 byte, which is exactly the range needed for one colour channel (0–255). So #FF = 11111111 = 255 — maximum brightness for that channel.
The #RRGGBB format stores three bytes: one for red, one for green, one for blue. This gives 256 × 256 × 256 = 16 777 216 possible colours (24-bit "true colour"). Modern displays also support 32-bit colour with an alpha (transparency) channel: #RRGGBBAA. Some professional tools use 48-bit colour (16 bits per channel) for editing precision, though displays cannot show the full range yet.
Practice questions
What colour is #FF0000?
- Green
- Blue
- White
- Red
(1 marks)
Convert the hex number B4 to decimal.
(2 marks)
Summary
- Convert between binary, decimal and hexadecimal.
- Explain the RGB colour model and how hex codes represent colours.
- Explain file size units from bits to terabytes.