Interactive Lessons

Number bases: binary, octal, hexadecimal and others

Lecture notes

Definition

A number system with a base

We write numbers in base ten: every place is worth ten times the place on its right (1, 10, 100, …) and we use ten digits, 0 to 9. In base b every place is worth b times the place on its right (1, b, b², …) and the digits are 0 to b − 1. Base 2 uses 0 and 1, base 8 uses 0 to 7. In Write in base b you choose a number and a base and see the place values and the digits.
Example
The number written in base 2 has the place values 8, 4, 2, 1 from the left. The digits are 1, 0, 1, 1, so the number is (in base ten).
84211011
Rule

Read a number in base b

To find the value of a number written in base b, multiply every digit by its place value and add the results. Write the place values from the right: 1, b, b², … In Read in base b you type the digits and choose the base; a digit that the base does not use gets a message.
Example
2D in base 16: the place values are 16 and 1 and D = 13, so . And 134 in base 5 → .
2551134
Rule

Write a number in base b: divide again and again

Divide the number by b. Write down the remainder. Divide the quotient by b again, and go on until the quotient is 0. The remainders, read from the bottom to the top, are the digits. In Write in base b the table of divisions and remainders is on the screen.
Example
45 in base 2 → remainder 1, remainder 0, remainder 1, remainder 1, remainder 0, remainder 1. Read from the bottom: . Check → .
Definition

Hexadecimal: base 16 and the letters A to F

Base 16 needs sixteen digits. After 9 we use letters: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. Base 2 is called binary, base 8 octal and base 16 hexadecimal. Computers use binary; hexadecimal is a short way to write long binary numbers.
Example
FF in base 16 → . And 1F4 → . In the application you can type the letters in capitals or in small letters.
Rule

Change from one base to another

Go through base ten. First find the value of the number in base ten (card 1), then write that value in the new base (card 2). If the two bases are the same, the digits stay the same. In Change base you type digits in base p and choose the new base q; both steps are shown.
Example
213 in base 4 to base 5 → in base ten. Then , so the digits are in base 5.
1641213
Tip

Adding in base 2

Add column by column from the right, like in base ten, but in base 2: write 0 and carry 1. Or change both numbers to base ten, add, and write the sum in base 2.
Example
Add and : in base ten , and = in base 2. Column by column: the right column , write 0, carry 1 …
Watch out!

Common mistakes with bases

(1) Reading the digits as if the base were ten: 101 in base 2 is not one hundred and one. (2) Using a digit that the base does not have: a digit is always smaller than the base. (3) Reading the remainders from the top to the bottom: read them from the bottom to the top. (4) Forgetting that the letters start at 10.
Example
101 in base 2 is , not 101. And 175 is not a number in base 5: the digit 7 is too big, the digits of base 5 are 0, 1, 2, 3 and 4.
Special case

The biggest number with n digits

The number 10 in base b is the number b itself. The biggest number with n digits in base b has all digits b − 1 and is worth . Base ten works the same way → .
Example
Four digits in base 2: = . Three digits in base 16: FFF = .
Tip

Typing digits, and nothing is sent anywhere

In Read in base b and Change base you type at most 12 digits: 0 to 9 and the letters A to F, in capitals or small letters. A digit that is too big for the base gets a message that lists the digits of the base. Everything you type is checked in your browser and sent nowhere.
Example
Type 2d in base 16: the application reads it as 2D and gives 45. Type 9 in base 8: the message says that the digits of base 8 are 0 to 7.

Exercises

What number is (base 2) in base ten? Easy
Show solution
The place values of 4 digits in base 2 are 8, 4, 2, 1.
Multiply and add → .
13
A 0 adds nothing: only the places with a 1 are counted.
Write 37 in base 2. Easy
Show solution
Divide by 2 again and again → remainder 1, remainder 0, remainder 1, remainder 0, remainder 0, remainder 1.
Read the remainders from the bottom to the top.
Check → .
Reading the remainders from the top to the bottom gives , which is a different number.
Is a number in base 5? Say why. Easy
Show solution
The digits of base 5 are 0, 1, 2, 3 and 4: every digit is smaller than 5.
The last digit of is 5, and 5 is not smaller than 5.
No: the digit 5 is not used in base 5.
In base 5 the number after 4 is written 10. The number is a number in base 5.
Write 3C (base 16) in base 2. Go through base ten. Medium
Show solution
C = 12, so 3C = in base ten.
Divide 60 by 2 → remainder 0, remainder 0, remainder 1, remainder 1, remainder 1, remainder 1.
Read from the bottom: . Check → .
Both steps use the same rules: read with place values, write with repeated division.
Write 156 in base 5. Medium
Show solution
remainder 1, remainder 1, remainder 1, remainder 1.
All the remainders are 1, so the digits are . Check → .
The place values of base 5 are 1, 5, 25, 125: 156 is one of each.
Which number is the biggest: (base 2), 24 (base 5), 15 (base 8) or C (base 16)? Medium
Show solution
Write every number in base ten: is .
24 in base 5 is , 15 in base 8 is and C is 12.
24 in base 5 (the value 14)
The number with the most digits is not always the biggest: the base counts too.
In base b the number 34 is worth 22 in base ten. Find b. Hard
Show solution
The place values are b and 1, so 34 in base b is .
Solve → , so .
Check: the digits 3 and 4 are smaller than 6, and .
b = 6
The base must be bigger than the biggest digit, here bigger than 4.
Add and in base 2 and write the sum in base 2. Hard
Show solution
In base ten: is and is .
The sum is .
25 in base 2 → , so the digits are .
Column by column: the sum has a carry in several places, because in base 2.
What is the biggest number that you can write with 5 digits in base 2? How many different numbers can you write with 5 digits (a number may start with 0)? Hard
Show solution
The biggest number has all digits 1: = .
Another way: 2 to the power 5 is 32 and .
The numbers go from 0 to 31, so there are of them. Every digit has 2 choices → .
31, and 32 different numbers
With n digits in base b there are b to the power n numbers, from 0 to that number minus 1.

Interactive applications for this topic

Free applications open with a free student account. Teachers can use all applications in a live lesson.

About the free account and Plus

Are you a teacher?

Start live lessons with these applications for your whole class. Free to try for one month.

Try it free

Fits these school years

IB (MYP, Diploma): MYP 4, MYP 5

What the applications of this topic teach 1 application

Numbers in other bases: write, read and change

  • Writing a number in a base from 2 to 16 and reading it in base ten
  • Explaining place values and the letters A to F
  • Converting a number from one base to another