Hexadecimal and colour codes
About this lesson: Hexadecimal and colour codes
In short
A byte is 8 bits. Rows of 0s and 1s are hard for people to read, copy and check. Hexadecimal writes every 4 bits as one symbol. Slide to try other bytes.

What you'll explore
- Why hex?: Binary is long for humans
- A byte is 8 bits. Rows of 0s and 1s are hard for people to read, copy and check. Hexadecimal writes every 4 bits as one symbol.
- Base 16: Sixteen digits: 0 to F
- Hex is base 16, so it needs 16 digits. After 9 it runs out of number symbols and uses the letters A to F.
- Binary to hex: Split into groups of four
- Split the byte into two nibbles of 4 bits. Each nibble uses the place values 8, 4, 2 and 1, and becomes one hex digit. Tap the bits to change them.
- Hex to denary: The 16s and the 1s
- In a two-digit hex number the columns are worth 16 and 1. Multiply the left digit by 16, then add the right digit.
- Denary to hex: Divide by sixteen
- Divide the number by 16. The whole-number answer is the left hex digit and the remainder is the right one. Then check by working backwards.
- Hex in real life: Colours are hex codes
- Screens mix red, green and blue light. A colour code like #FF8800 gives each light a value from 00 (off) to FF (full).
- Check yourself: Read a hex number
- A program's error message shows the hex number 2C. You want to know its value in denary.
Also in this lesson
- Step by step
- Common mix-ups
- Hex in the real world
- How many values can you write?
- More than the lesson
- Explaining why hex is used
- Stretch your brain
- Hex detective
Words to know
- hexadecimal (hex)
- A number system with base 16, using the digits 0–9 and A–F.
- base
- How many different digits a number system uses: binary 2, denary 10, hex 16.
- denary
- Our everyday base-10 number system.
- binary
- Base 2: only 0 and 1. How computers store all data.
- bit
- One binary digit: 0 or 1.
- nibble
- 4 bits: exactly one hex digit.
- byte
- 8 bits: exactly two hex digits, values 00 to FF (0 to 255).
- place value
- What a column is worth. Hex columns: 1, 16, 256, 4096…
- RGB
- Red, green and blue: the three lights a screen mixes to make every colour.
- colour code
- A colour written as #RRGGBB in hex.
- MAC address
- A unique 48-bit number for a network card, written in hex.
Sources
- BBC Bitesize, GCSE Computer Science: Hexadecimal
- Isaac Computer Science: Number bases
- MDN Web Docs: CSS colour values (hex notation)
- IEEE: Guidelines for EUI-48 (MAC) addresses