Number systems

Computer Science · Data representation. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science topics

The idea

A computer is built from millions of tiny switches that are either on or off. So all data, whether numbers, text, sound or images, is stored as binary: patterns of 1s and 0s.

Denary uses place values 1, 10, 100. Binary uses 1, 2, 4, 8, 16, 32, 64, 128. Hexadecimal uses 16 digits, 0 to 9 then A to F (A = 10, F = 15). One hex digit stands for exactly four bits, so hex is shorter and easier for people to read than binary.

You must also add 8-bit numbers, shift them left or right, and write negative numbers in two's complement, where the left-most bit is worth −128.

Rules to remember

Common mistake

Students read a hex digit such as C as a denary 12 and then forget to multiply by its place value. In 3C the 3 is worth 3 × 16, not 3.

Worked example

Convert the denary number 219 to hexadecimal.

  1. Divide by 16: 219 ÷ 16 = 13 remainder 11 (13 × 16 = 208, 219 − 208 = 11).
  2. 13 is the hex digit D and 11 is the hex digit B.
  3. Check in binary: D = 1101, B = 1011, and 1101 1011 = 128 + 64 + 16 + 8 + 2 + 1 = 219.

Answer: 219 in denary is DB in hexadecimal.

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

Text, sound and images →Take a Computer Science test