Converting whole numbers to their hex equivalents — step by step, remainder by remainder
When a graphics card renders a pixel with a red value of 220, it needs to store that as hex to pack it into a colour code. When a router assigns a MAC address, it converts hardware IDs to hex. When a web developer reads a debug log, every memory address they see was converted from a raw denary integer — automatically, thousands of times per second. The conversion you're learning today is the exact algorithm every programming language uses internally when you call a function like hex(220) or toString(16). It is also one of the most reliably tested Cambridge Paper 1 skills — appearing in virtually every past paper under Data Representation.
The method mirrors converting denary to binary — but instead of dividing by 2, you divide by 16. Each remainder becomes one hex digit. Because 16² = 256, any value from 0 to 255 (one byte) can always be expressed in exactly two hex digits.
Divide your denary number by 16. Record the remainder (0–15). If the remainder is 10–15, convert it to the hex letter A–F.
Take the quotient and divide by 16 again. Record the remainder. Repeat until the quotient becomes 0.
Read the remainders bottom to top. The last remainder is the most significant hex digit (written first, on the left).
For values 0–255, pad to two hex digits with a leading 0 if needed (e.g. denary 7 → hex 07, not just 7).
Read bottom to top: DC. Verify: (D × 16) + (C × 1) = (13 × 16) + 12 = 208 + 12 = 220 ✓
This is where students most often lose marks. Any remainder of 10 or above must be converted to its hex letter before writing:
Writing the remainder as denary — if your remainder is 13, write D, not 13. Writing "13" as a hex digit is wrong and loses the mark.
Reading remainders top to bottom — always bottom to top. The first remainder you calculate is the units (low) hex digit, not the high digit.
Forgetting to pad to two digits — if your number is less than 16, the answer is 0X (e.g. denary 9 → hex 09). A single digit answer will lose the mark if two are expected.
Not verifying — always check by converting back: multiply each hex digit by its place value (×16 and ×1) and add. If it doesn't match your original number, an error was made.
This example produces a remainder of 7 and a quotient remainder of 12 — testing both a number digit and a letter digit.
Show the full division table. Always verify your answer by converting back.
Division steps, remainder-to-letter conversions, and common error traps. Complete all 5 to save your progress!