Binary and number bases

We count in tens because we have ten fingers, but any whole number can be written in any base. Computers use base 2 (binary), and programmers use base 16 (hexadecimal) as a compact way to write binary. Converting between bases is all about place value.

Key facts

  • In base b the columns are worth 1, b, b², b³, … from the right, and the digits run from 0 to b − 1.
  • To convert to denary, multiply each digit by its column value and add.
  • From denary, divide repeatedly by the base. The remainders, read from the bottom up, are the digits.
  • Hexadecimal digits are 0–9 then A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. Each hex digit is exactly 4 bits.
  • n bits can store 2ⁿ different values, from 0 to 2ⁿ − 1.
  • Binary addition: 1 + 1 = 10 (write 0, carry 1) and 1 + 1 + 1 = 11 (write 1, carry 1).

Worked examples

Example 1

Convert 101101₂ to denary.

  1. Columns from the right: 1, 2, 4, 8, 16, 32.
  2. Add the columns holding a 1. 32 + 8 + 4 + 1 = 45

Answer: 45

Example 2

Convert 200 to binary and to hexadecimal.

  1. 200 = 128 + 64 + 8. Put 1s in those columns. 200 = 11001000₂
  2. Split into groups of four bits: 1100 and 1000.
  3. 1100 is 12, which is C. 1000 is 8. 200 = C8₁₆

Answer: 11001000₂ = C8₁₆

Example 3

A number is written 132 in base b. It equals 56 in denary. Find b.

  1. 132 in base b means b^2 + 3b + 2 = 56
  2. Rearrange and factorise. b^2 + 3b − 54 = (b + 9)(b − 6) = 0
  3. b must be positive, so b = 6. Every digit is less than 6. ✓ 36 + 18 + 2 = 56

Answer: b = 6

Example 4

Convert 13 to binary.

  1. The binary place values are 8, 4, 2 and 1.
  2. 13 = 8 + 4 + 1 13 = 8 + 4 + 1
  3. Put a 1 under each value used. 1101₂

Answer: 1101₂

Example 5

Convert 11010₂ to base 10.

  1. Write the place values above the digits. 16, 8, 4, 2, 1
  2. Add the values with a 1. 16 + 8 + 2 = 26

Answer: 26

Example 6

Convert 2F₁₆ to base 10.

  1. F stands for 15.
  2. The 2 is in the 16s column. 2 × 16 + 15 = 47

Answer: 47

Example 7

Work out 1011₂ + 110₂.

  1. Add from the right and carry when a column makes 2. 1 + 1 = 10₂
  2. Write the answer. 1011₂ + 110₂ = 10001₂

Answer: 10001₂

Example 8

Convert 0.101₂ to base 10.

  1. The binary place values after the point are 1/2, 1/4 and 1/8.
  2. Add the values with a 1. 0.5 + 0.125 = 0.625

Answer: 0.625

Example 9

Convert 25 to binary.

  1. The binary place values are 16, 8, 4, 2 and 1.
  2. 25 = 16 + 8 + 1 25 = 16 + 8 + 1
  3. Put a 1 under each value used. 11001₂

Answer: 11001₂

Example 10

Convert 255 to hexadecimal.

  1. 255 ÷ 16 = 15 remainder 15
  2. 15 is F in hexadecimal. FF₁₆

Answer: FF₁₆