Why is a colour on your school website written as #FF0000?
You spot a bright red banner on your school website. In the page code, its colour is written as a hash followed by F F and four zeros. Why would someone use letters to write a number?
In decimal, or base ten, you use digits zero to nine. From the right, the places are ones, tens and hundreds. In binary, or base two, you use zero and one. The places go ones, twos and fours. Computers use patterns of bits to represent all data and instructions.
After nine comes A, worth ten. The letters run through to F, worth fifteen. Add one to F and you get one sixteen and zero ones. Each place is worth sixteen times the place to its right, so the next place is worth two hundred and fifty-six. That's base sixteen.
You're counting in hexadecimal and you've just reached one F. Move forward by one. Think about what happens to the ones place when F runs out. Pick the number that comes next.
Each bit has two possible values. Take four bits and multiply two choices by two, by two, and by two again. That's sixteen possible patterns, exactly as many as there are digits in hexadecimal.
Use the binary place values: eight, four, two and one. Four zeros give zero. Only the ones bit is set in the next row, giving one. For one zero one zero, add eight and two to get ten, or A. Four ones give fifteen, or F.
Start with this twelve-bit string. Group it in fours from the right so the rightmost group gives the hex ones digit. One zero one zero gives A, four ones give F, and zero zero zero one gives one. Join them in that order: A F one.
Read the groups from left to right: one zero one zero, four zeros, then four ones. Give each group its own digit, even if that digit is zero. Pick the matching hexadecimal number.
A F one takes three digits to write, so you might think it needs just three bits to store. Compare those three digits with the three groups of four bits. If the value is stored in a twelve-bit field, that field still uses twelve bits.
Look back at the red banner. Its binary colour value has twenty-four bits. The web colour code writes that value as six hex digits after a hash. If an exam asks why hexadecimal is used to represent binary values, explain that fewer digits make copying easier and mistakes less likely.