lnf.cymru stimulus sheet · Computer Science · Year 9

Theatr y Glannau: matching the stage lights to the website

The theatre, the people and the colours on this sheet are invented. Hexadecimal colour codes and the number methods are real and are used on every website.

1. The problem

Theatr y Glannau is a small theatre on the coast near Aberaeron. Its website uses four brand colours, written as hexadecimal colour codes such as #FF8800. The theatre’s new LED stage lights can glow in any colour, but the lighting desk only accepts denary numbers from 0 to 255 for red, green and blue.

Rhys, the lighting technician, writes: “I want the stage to glow in exactly the website colours. I also need to turn two of my lighting scenes into hex codes for the website. Can you do the conversions for me?”

2. How a colour code works

A colour code has 6 hex digits in 3 pairs: RR GG BB. Each pair is the amount of red, green or blue, from 00 (none) to FF (full). Each pair is one byte, so it can store 256 different values, 0 to 255.

3. Place value in three number systems

SystemBaseColumn values, right to left
Denary101, 10, 100, 1,000 (powers of 10)
Binary21, 2, 4, 8, 16, 32, 64, 128 (powers of 2)
Hexadecimal161, 16, 256 (powers of 16)

Hex digits

Hex needs 16 digits, so after 9 it uses letters.

Hex0123456789ABCDEF
Denary0123456789101112131415
Binary0000000100100011010001010110011110001001101010111100110111101111

4. Methods, with a worked example

Hex to denary

Multiply the left digit by 16, then add the right digit. 88 = (8 × 16) + 8 = 128 + 8 = 136 FF = (15 × 16) + 15 = 240 + 15 = 255

Hex to binary

Each hex digit becomes 4 bits (a nibble). Write the two nibbles side by side. 88 = 1000 1000 = 10001000 FF = 1111 1111 = 11111111

Denary to hex

Divide by 16. The whole number answer is the left digit. The remainder is the right digit. 136 ÷ 16 = 8 remainder 8, so 136 = 88 90 ÷ 16 = 5 remainder 10, and 10 is A, so 90 = 5A

Binary to hex

Split the 8 bits into two nibbles. Change each nibble to one hex digit. 1001 1110 = 9 and 14 = 9E

Check any answer by converting it back the other way.

5. The website colours

Colour nameHex codeWhat it is used for
Harbour orange (worked example)#FF8800Buttons. Red 255, green 136, blue 0.
Sea-grass green#1E5A3CThe logo
Sand gold#F2C14EHeadings
Lifeboat red#D7263D“Sold out” labels

6. Rhys’s lighting scenes

SceneRedGreenBlue
Sunset2004599
Moonlight128128255

7. Binary shifts

00000110 (6) left shift 1 place = 00001100 (12)