learn › Number Theory

Number bases

lesson · about 3 minutes

Binary and hexadecimal: the numbers computers use.

Pen and paper is fine · no calculator needed why?

Opens at level 25. You're level 1. You can read and practice here now.

the idea

Our numbers are base 10: each place is worth ten times the place to its right. Other bases work the same way with a different multiplier.

Binary (base 2) uses only the digits 0 and 1, and its places are 1, 2, 4, 8, 16, 32 and so on, doubling from the right. Computers use it because a switch is either off or on.

Hexadecimal (base 16) needs sixteen digits, so after 9 come the letters A to F for 10 to 15. Its places are 1, 16, 256 and so on.

techniques

Add the places that are on

Turning a binary number into decimal.

  1. Write the place values over the digits: 1 on the right, doubling as you go left.
  2. Add the place values that have a 1 under them.
worked example

Example: What is the binary number 1 0 1 1 0 1 in decimal? Its digits are spaced out for reading.

  1. Places from the right: 1, 2, 4, 8, 16, 32.
  2. The 1s sit under 32, 8, 4 and 1.
  3. 32 + 8 + 4 + 1 = 45.

Answer: 45

Take the biggest power of 2

Turning a decimal number into binary.

  1. Find the largest power of 2 that fits, and take it away.
  2. Repeat with what is left until nothing remains.
  3. Write 1 in each place you used and 0 in the others, largest place first.
  4. 37 is 32 + 4 + 1, which gives the digits 1 0 0 1 0 1.
worked example

Example: Write 6 in binary.

  1. 6 = 4 + 2.
  2. Places 4, 2 and 1 get 1, 1 and 0.
  3. So 6 is 110 in binary.

Answer: 110

Sixteens and ones

Turning a hexadecimal number into decimal.

  1. Swap each letter for its value: A is 10, B 11, C 12, D 13, E 14, F 15.
  2. Two digits: the left one counts sixteens and the right one counts ones.
  3. Three digits: the places are 256, 16 and 1.
worked example

Example: What is hexadecimal 3C in decimal?

  1. C is 12.
  2. 3 × 16 + 12 = 48 + 12 = 60.

Answer: 60

watch out for

practice

Sign in to try one

Binary to decimal

worked example

What is the binary number 10011 in decimal?

Answer: 19

  1. Place values from the right: 1, 2, 4, 8, 16.
  2. The places with a 1: 16 + 2 + 1 = 19.

Decimal to binary

worked example

Write 68 in binary.

Answer: 1000100

  1. Take the largest powers of 2 that fit: 68 = 64 + 4.
  2. Places 64, 32, 16, 8, 4, 2, 1 get 1 0 0 0 1 0 0, so 68 is 1000100 in binary.

Hexadecimal

worked example

What is hexadecimal A75 in decimal?

Answer: 2,677

  1. Hexadecimal places are 256, 16 and 1.
  2. A75 = A (10) × 256 + 7 × 16 + 5 = 2,560 + 112 + 5 = 2,677.

Sign in to start