{"base":{"id":"cs10-02","subject":"Data representation","title":"Hexadecimal and colour codes","scene":"bits10","steps":[{"mode":"why","eyebrow":"Why hex?","title":"Binary is long for humans","body":"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.","controls":[{"id":"n","label":"A byte (as denary)","min":0,"max":255,"step":1,"value":214}]},{"mode":"digits","eyebrow":"Base 16","title":"Sixteen digits: 0 to F","body":"Hex is base 16, so it needs 16 digits. After 9 it runs out of number symbols and uses the letters A to F. Slide, or tap a tile, to see each digit in denary and binary.","controls":[{"id":"d","label":"Digit value","min":0,"max":15,"step":1,"value":13}]},{"mode":"nibble","eyebrow":"Binary to hex","title":"Split into groups of four","body":"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.","actions":[{"id":"new","label":"Show another byte"}]},{"mode":"toDen","eyebrow":"Hex to denary","title":"The 16s and the 1s","body":"In a two-digit hex number the columns are worth 16 and 1. Multiply the left digit by 16, then add the right digit. Can you make the biggest two-digit hex number?","controls":[{"id":"hi","label":"Left digit (16s), value 0–15","min":0,"max":15,"step":1,"value":13},{"id":"lo","label":"Right digit (1s), value 0–15","min":0,"max":15,"step":1,"value":6}]},{"mode":"toHex","eyebrow":"Denary to hex","title":"Divide by sixteen","body":"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.","controls":[{"id":"n","label":"Denary number","min":0,"max":255,"step":1,"value":200}]},{"mode":"colour","eyebrow":"Hex in real life","title":"Colours are hex codes","body":"Screens mix red, green and blue light. A colour code like #FF8800 gives each light a value from 00 (off) to FF (full). Tap − and + on the picture, or try a colour.","actions":[{"id":"c0","label":"Orange"},{"id":"c1","label":"Ocean blue"},{"id":"c2","label":"Leaf green"},{"id":"c3","label":"Grape"}]},{"mode":"quiz","look":"digits","eyebrow":"Check yourself","title":"Read a hex number","body":"A program's error message shows the hex number 2C. You want to know its value in denary.","question":"What is hex 2C in denary?","options":["44","212","32"],"answer":0,"right":"Correct. 2 × 16 = 32, and C is 12, so 32 + 12 = 44.","wrong":"Not quite. The left digit counts 16s. What is C worth on its own?"}],"more":[{"type":"cards","id":"worked","eyebrow":"Worked examples","title":"Step by step","intro":"The fastest route between binary and hex is always through nibbles. Between hex and denary, use the 16s column.","items":[{"tag":"Binary → hex","title":"10110111","body":"split:   1011 | 0111\nleft:    8 + 2 + 1 = 11 → B\nright:   4 + 2 + 1 = 7  → 7\nanswer:  B7","code":true},{"tag":"Hex → binary","title":"3F","body":"3 → 0011   (always write 4 bits)\nF → 15 → 1111\nanswer:  0011 1111","code":true},{"tag":"Hex → denary","title":"A7","body":"A = 10 → 10 × 16 = 160\n7 = 7  →  7 × 1  =   7\nanswer:  160 + 7 = 167","code":true},{"tag":"Denary → hex","title":"235","body":"235 ÷ 16 = 14 remainder 11\n14 → E      11 → B\nanswer:  EB\ncheck:   14 × 16 + 11 = 224 + 11 = 235 ✓","code":true}]},{"type":"cards","id":"mistakes","eyebrow":"Popular idea vs fact","title":"Common mix-ups","items":[{"tag":"Popular idea","title":"\"Computers store numbers in hex.\"","body":"Computers only store binary. Hex is a way of showing binary to people. The chip never sees the letters A to F."},{"tag":"Popular idea","title":"\"Hex saves memory.\"","body":"The value D6 and the value 11010110 take exactly the same 8 bits. Only the written form is shorter."},{"tag":"Popular idea","title":"\"10 in hex means ten.\"","body":"It means one 16 and no 1s: sixteen. Hex ten is A."},{"tag":"Mistake","title":"Dropping leading zeros in a nibble","body":"Hex 3 is 0011, not 11. Each hex digit must become exactly 4 bits, or the binary number shifts and changes value."},{"tag":"Mistake","title":"Reading C as 13","body":"Count from A = 10: A 10, B 11, C 12, D 13, E 14, F 15. A quick check: F is always 15, one less than 16."}]},{"type":"cards","id":"uses","eyebrow":"Where you meet hex","title":"Hex in the real world","items":[{"tag":"Web and design","title":"Colour codes: #RRGGBB","body":"Two hex digits each for red, green and blue light. 256 × 256 × 256 = 16 777 216 possible colours, called 24-bit colour.\n\n#FF0000 red · #00FF00 green · #0000FF blue · #FFFF00 yellow (red + green light) · #FFFFFF white · #000000 black."},{"tag":"Networks","title":"MAC addresses","body":"Every network card has a MAC address of 6 bytes, written as 12 hex digits, for example 3C:5A:B4:1E:09:F2. The first half shows the company that made the card."},{"tag":"Networks","title":"IPv6 addresses","body":"The newer internet addresses are 128 bits long. Written in binary they would be 128 digits; in hex they are 32, grouped like 2001:0db8:85a3:0000:0000:8a2e:0370:7334."},{"tag":"Programming","title":"Memory addresses and error codes","body":"When a program crashes it often shows where in memory it was, such as 0x7FFE45A2. The 0x at the front is how many programming languages say \"this is hex\"."},{"tag":"The web","title":"%20 in a web address","body":"Spaces are not allowed in URLs, so a space is written %20. Hex 20 is 32 in denary, the ASCII code for a space."}]},{"type":"bars","id":"values","eyebrow":"Data","title":"How many values can you write?","intro":"Each extra hex digit multiplies the number of values by 16. (The bars use a stretched scale, or the last one would be a kilometre long.)","items":[{"label":"1 hex digit (4 bits)","value":20,"display":"16 values","color":"#6d4ee0"},{"label":"2 digits (1 byte)","value":38,"display":"256 values","color":"#0f9f75"},{"label":"3 digits","value":56,"display":"4 096 values","color":"#2f6fdb"},{"label":"4 digits","value":72,"display":"65 536 values","color":"#d4920f"},{"label":"6 digits (a colour)","value":100,"display":"16 777 216 values","color":"#db2777"}],"facts":[{"title":"Place values in hex","body":"From the right: 1, 16, 256, 4096 … each column is 16 times the one before. So hex 1F4 = 1 × 256 + 15 × 16 + 4 = 500."},{"title":"Why not base 10?","body":"Ten is not a power of 2, so denary digits do not line up with bits. Sixteen is 2⁴, so one hex digit is exactly four bits. That makes converting quick and error-free."}]},{"type":"cards","id":"deeper","eyebrow":"Go deeper","title":"More than the lesson","items":[{"tag":"Fun fact","title":"Hexspeak","body":"Because hex uses A to F, programmers hide words in numbers. 0xCAFE, 0xBEEF and 0xC0FFEE are all real values that turn up in code, often as markers that are easy to spot in a memory dump."},{"tag":"History","title":"Octal came first","body":"Some early computers grouped bits in threes and used base 8 (octal, digits 0–7). When the 8-bit byte became standard in the 1960s, base 16 fitted better: two hex digits per byte."},{"tag":"How colours work","title":"Why red + green = yellow on a screen","body":"Screens add light, so mixing works differently from paint. Red light plus green light reaches your eyes and looks yellow. All three at full power look white. Paint does the opposite: it removes light."},{"tag":"Coming next","title":"Bigger and negative numbers","body":"Next you will add binary numbers, see what happens when a byte overflows past 255, and learn two's complement, the way computers store negative numbers."}]},{"type":"cards","id":"exam","eyebrow":"Set out your answer","title":"Explaining why hex is used","items":[{"tag":"Good answer","title":"Give two clear reasons","body":"\"Hex is shorter than binary, so it is easier for people to read and remember. It is also less likely to be copied wrongly. Each hex digit stands for exactly 4 bits, so it converts to and from binary easily.\""},{"tag":"Weak answer","title":"Avoid these","body":"\"Hex is faster for the computer\" and \"hex uses less storage\" are both wrong: the computer still works in binary, and the number of bits is the same."},{"tag":"Show working","title":"Conversions","body":"Write the nibbles or the 16s and 1s columns. If one digit slips you still keep method marks, and you can check by converting back."}]},{"type":"cards","id":"challenge","eyebrow":"Challenge yourself","title":"Stretch your brain","intro":"Try each one on paper before opening the card.","items":[{"tag":"Challenge","title":"What is the largest number you can write with 4 hex digits? Give it in denary.","body":"FFFF = 15 × 4096 + 15 × 256 + 15 × 16 + 15\n= 61 440 + 3 840 + 240 + 15\n= 65 535\n(It is 16⁴ − 1, the same as 16 bits all set to 1.)","code":true},{"tag":"Challenge","title":"A colour code is #3C9. Some websites allow this 3-digit short form. What is the full 6-digit code?","body":"Each digit is doubled: 3 → 33, C → CC, 9 → 99.\nFull code: #33CC99 (red 51, green 204, blue 153), a fresh mint green."}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Hex detective","items":[{"title":"Colour detective","time":"20 minutes","need":["A computer or tablet","A free drawing app, or a web search for \"colour picker\""],"steps":["Open a colour picker. Choose your favourite colour and write down its hex code.","Split it into RR, GG and BB. Convert each pair to denary.","Predict a colour before you see it: what will #FFC0CB and #808080 look like? Type them in to check.","Make the darkest red you can that still looks red. What is its code?"],"why":"Each pair controls one colour of light from 0 to 255. Bigger numbers mean brighter light. Equal pairs always give a grey.","safety":"Use apps and websites a parent or teacher trusts."},{"title":"Write your name in hex","time":"15 minutes","need":["Paper and pencil","An ASCII table (search \"ASCII table\")"],"steps":["Look up the ASCII code of each letter of your name. Capital A is 65, B is 66, and so on.","Convert each code to hex. A = 65 = 41, B = 42 …","Write your name as a row of hex pairs, like 4C 65 6F for \"Leo\".","Give a hex message to a friend and decode theirs."],"why":"Text is stored as numbers, one per character. Hex is the usual way programmers look at those numbers.","safety":"No safety risks."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Eight more questions","questions":[{"question":"How many bits does one hex digit stand for?","options":["4","8","16"],"answer":0,"right":"Correct. 4 bits give 2⁴ = 16 patterns, one for each hex digit.","wrong":"Not quite. How many bits give exactly 16 different patterns?"},{"question":"What is binary 1111 0000 in hex?","options":["F1","F0","150"],"answer":1,"right":"Correct. 1111 = 15 = F and 0000 = 0, so F0.","wrong":"Not quite. Convert each group of 4 bits on its own."},{"question":"What is hex 1A in denary?","options":["110","10","26"],"answer":2,"right":"Correct. 1 × 16 + 10 = 26.","wrong":"Not quite. The 1 is in the 16s column, and A is worth 10."},{"question":"Which colour is #00FF00?","options":["Bright green","Red","Black"],"answer":0,"right":"Correct. Red 00, green FF (full), blue 00.","wrong":"Not quite. The middle pair controls green light."},{"question":"What is denary 100 in hex?","options":["A0","64","100"],"answer":1,"right":"Correct. 100 ÷ 16 = 6 remainder 4, so 64. Check: 6 × 16 + 4 = 100.","wrong":"Not quite. Divide 100 by 16 and look at the remainder."},{"question":"Why do programmers often write hex instead of binary?","options":["It uses less memory","Computers store hex","It is shorter and easier to read"],"answer":2,"right":"Correct. Same bits, but fewer symbols for people to read and copy.","wrong":"Not quite. The computer itself always stores binary."},{"question":"What number comes straight after hex 19?","options":["20","1A","1F"],"answer":1,"right":"Correct. After 9 comes A, so 19 is followed by 1A (25 then 26 in denary).","wrong":"Not quite. In hex, what digit comes after 9?"},{"question":"A MAC address is 12 hex digits long. How many bits is that?","options":["48","12","96"],"answer":0,"right":"Correct. 12 digits × 4 bits = 48 bits (6 bytes).","wrong":"Not quite. Each hex digit is 4 bits."}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can…","items":["explain why people use hex instead of long binary numbers","list the 16 hex digits and say what A to F are worth","convert binary to hex by splitting into nibbles","convert hex to binary, always writing 4 bits per digit","convert two-digit hex to denary using the 16s and 1s columns","convert denary up to 255 into hex by dividing by 16","read a #RRGGBB colour code and predict the colour","name three places hex is used: colours, MAC addresses, memory addresses"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"hexadecimal (hex)","meaning":"A number system with base 16, using the digits 0–9 and A–F."},{"word":"base","meaning":"How many different digits a number system uses: binary 2, denary 10, hex 16."},{"word":"denary","meaning":"Our everyday base-10 number system."},{"word":"binary","meaning":"Base 2: only 0 and 1. How computers store all data."},{"word":"bit","meaning":"One binary digit: 0 or 1."},{"word":"nibble","meaning":"4 bits: exactly one hex digit."},{"word":"byte","meaning":"8 bits: exactly two hex digits, values 00 to FF (0 to 255)."},{"word":"place value","meaning":"What a column is worth. Hex columns: 1, 16, 256, 4096…"},{"word":"RGB","meaning":"Red, green and blue: the three lights a screen mixes to make every colour."},{"word":"colour code","meaning":"A colour written as #RRGGBB in hex."},{"word":"MAC address","meaning":"A unique 48-bit number for a network card, written in hex."}]},{"type":"sources","id":"sources","title":"Sources","items":["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"]}]},"overlay":null}