• Foundation
  • About 14 min
  • 5 practice questions

Number systems: decimal, binary, octal and hexadecimal

Read place values in binary, convert small numbers between binary and decimal, and group bits to write octal and hexadecimal.

If something looks wrong, please tell us.

We count in tens because we have ten fingers, but a computer counts in twos because its circuits have two states: on and off. This lesson shows how the same number looks in four systems and how to move between them. The method is simple and needs only addition and division by 2.

What a number system is

A number system has a base, the count of different digits it uses. The value of each digit depends on its place value, which is a power of the base. In decimal (base 10) the places are 1, 10, 100 and so on. In binary (base 2) the places are 1, 2, 4, 8, 16 and so on.

Four number systems
SystemBaseDigits usedPlace values from the right
Binary20, 11, 2, 4, 8, 16, 32
Octal80 to 71, 8, 64, 512
Decimal100 to 91, 10, 100, 1000
Hexadecimal160 to 9 and A to F1, 16, 256, 4096

In hexadecimal the letters stand for numbers above 9: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

Binary to decimal

Write the place values under the bits, then add the place values where the bit is 1.

Worked example 1: 1011 in binary

The places from the right are 1, 2, 4, 8. The bits 1, 0, 1, 1 from left to right sit on 8, 4, 2, 1. So the value = 1 x 8 + 0 x 4 + 1 x 2 + 1 x 1 = 8 + 0 + 2 + 1 = 11.

Decimal to binary

Divide by 2 again and again, noting the remainder each time, until the quotient is 0. Then read the remainders from the last to the first.

Worked example 2: 45 in binary

Repeated division by 2
DivisionQuotientRemainder
45 / 2221
22 / 2110
11 / 251
5 / 221
2 / 210
1 / 201

Reading the remainders from the bottom up gives 101101. Check: 32 + 0 + 8 + 4 + 0 + 1 = 45.

Octal and hexadecimal as shortcuts

Because 8 = 2^3 and 16 = 2^4, one octal digit equals exactly 3 bits and one hexadecimal digit equals exactly 4 bits. To write 101101 in octal, group from the right in threes: 101 and 101, which are 5 and 5, giving 55 in octal. In hexadecimal, group in fours from the right, adding zeros on the left: 0010 and 1101, which are 2 and D (13), giving 2D. Both equal 45 in decimal: 5 x 8 + 5 = 45 and 2 x 16 + 13 = 45.

Binary to decimal: add the place values of the 1 bits. Decimal to binary: divide by 2 and read the remainders upwards.

Key takeaways

  • Base is the number of digits a system uses.
  • Binary places: 1, 2, 4, 8, 16, 32 from the right.
  • One octal digit = 3 bits; one hex digit = 4 bits.
  • In hex, A to F stand for 10 to 15.

Check your understanding

  1. 1. What is the decimal value of the binary number 1101?

    1. 15
    2. 9
    3. 13
    4. 11
    Show answer

    Answer: C. 1101 = 8 + 4 + 0 + 1 = 13.

  2. 2. What is the binary form of decimal 25?

    1. 11001
    2. 10101
    3. 11010
    4. 10011
    Show answer

    Answer: A. 25 = 16 + 8 + 1, so the bits for 16, 8 and 1 are set: 11001.

  3. 3. Which digits can appear in an octal number?

    1. 0 to 9
    2. 0 and 1
    3. 0 to 9 and A to F
    4. 0 to 7
    Show answer

    Answer: D. Octal has base 8, so the digits are 0 to 7.

  4. 4. What is the decimal value of the hexadecimal number 1A?

    1. 36
    2. 26
    3. 11
    4. 17
    Show answer

    Answer: B. 1A = 1 x 16 + 10 = 26.

  5. 5. How many different values can 4 bits represent?

    1. 15
    2. 32
    3. 16
    4. 8
    Show answer

    Answer: C. Each bit doubles the choices: 2 x 2 x 2 x 2 = 16 values, from 0000 to 1111.

Privacy · Terms · Refunds · Delivery