Study notes

Number Systems

How computers count in binary (base 2) and hexadecimal (base 16), and how to convert to and from our everyday denary (base 10).

Learn it step by step

Computers count in binary (base 2)

A computer only has two states: off (0) and on (1). Each digit is a bit. Unlike denary (base 10), each column is worth twice the one on its right.

Place value8421
Bit1010
Binary 1010 = 8 + 0 + 2 + 0 = 10 in denary

Binary to denary: add the ON place values

Write the place values (…16, 8, 4, 2, 1) above each bit, then add the values where the bit is 1.

32168421
101101
101101 = 32 + 8 + 4 + 1 = 45

Hexadecimal (base 16): shorthand for binary

Hex uses 16 digits: 0-9 then A-F (A=10 … F=15). One hex digit packs exactly 4 bits, so long binary numbers become short and readable.

DenaryBinaryHex
101010A
121100C
151111F
Each hex digit = 4 binary bits

Why programmers use hex

Colours (#FF8800), memory addresses and error codes are written in hex because it is far easier to read than a long string of 0s and 1s, while still mapping cleanly onto the binary the machine uses.

Worked examples

Convert the binary number 1101 to denary.
  1. Place values: 8, 4, 2, 1
  2. Bits: 1, 1, 0, 1 -> ON at 8, 4 and 1
  3. 8 + 4 + 0 + 1 = 13
Convert the denary number 45 to binary.
  1. Largest place value <= 45 is 32; 45 - 32 = 13
  2. 13: take 8 (13 - 8 = 5), take 4 (5 - 4 = 1), take 1
  3. Fill 1s at 32, 8, 4, 1 -> 101101
Convert the hexadecimal 2F to denary.
  1. 2F: the 2 is the 16s column, F is the 1s column
  2. F = 15
  3. (2 x 16) + 15 = 32 + 15 = 47

Mind map

Mind map for Number Systems.

  • Binary (base 2)
    • bits: 0 or 1
    • each column doubles
  • Denary (base 10)
    • our everyday digits 0-9
  • Hexadecimal (base 16)
    • digits 0-9, A-F
    • 1 hex digit = 4 bits
  • Converting
    • binary -> denary: add ON place values
    • denary -> binary: subtract place values
Practise this topic →