Chapter 3: Binary numbers
In Chapter 1 you learnt that we use the base ten number system for everyday counting. When we count using the base ten number system, we put objects in groups of ten. We use the numbers 0; 1; 2; 3; 4; 5; 6; 7; 8; 9 as digits to make any other number, no matter how big or how small it is.
The base ten number system is also called the decimal number system. The prefix "deci-" comes from a Latin word that means "one tenth".
3.1 The base two number system
In this chapter you will learn about the base two number system. The base two number system is used in computers and other devices that also use computing functions. It is therefore a very important number system.
When we count using the base two number system, we put objects in groups of two. We use only two digits, namely 0 and 1, to make up any number.
The base two number system is also called the binary number system. The prefix "bi-" comes from a Latin word that means "two" or "twice".
base ten number system The base ten number system is a number system that counts in groups of 10, and uses the digits 0; 1; 2; 3; 4; 5; 6; 7; 8; 9 to represent any number. It is also called the decimal number system.
base two number system The base two number system is a number system that counts in groups of 2, and uses only the digits 0 and 1 to represent any number. It is also called the binary number system.
Counting in the base two number system
In the base two number system, we go to a new group each time we reach a number that is a power of 2. We therefore
count as follows:
⊛1 unit⊛⊛1 group of two and 0 units⊛⊛⊛1 group of two and 1 unit
If we add another object, we have 2 groups of two, which is 4. We continue counting as follows:
⊛⊛⊛⊛1 group of four, 0 groups of two and 0 units⊛⊛⊛⊛⊛1 group of four, 0 groups of two and 1 unit⊛⊛⊛⊛⊛⊛1 group of four, 1 group of two and 0 units⊛⊛⊛⊛⊛⊛⊛1 group of four, 1 group of two and 1 unit
If we add another object, we have 3 groups of two, which is 8. We continue counting as follows:
⊛⊛⊛⊛⊛⊛⊛⊛1 group of eight, 0 groups of four, 0 groups of two and 0 units⊛⊛⊛⊛⊛⊛⊛⊛⊛1 group of eight, 0 groups of four, 0 groups of two and 1 unit⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛1 group of eight, 0 groups of four, 1 group of two and 0 units⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛1 group of eight, 0 groups of four, 1 group of two and 1 unit⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛1 group of eight, 1 group of four, 0 groups of two and 0 units
We can carry on like this. When we have 4 groups of two, we count in 16s.
3.2 Powers of 2
In the base ten number system we work with powers of 10. In the base two number system, we work with powers of 2.
The first ten powers of 2 are:
NameNumberPowers of 2Two22=21Four42×2=22Eight82×2×2=23Sixteen162×2×2×2=24Thirty two322×2×2×2×2=25Sixty four642×2×2×2×2×2=26One hundred and twenty eight1282×2×2×2×2×2×2=27Two hundred and fifty six2562×2×2×2×2×2×2×2=28Five hundred and twelve5122×2×2×2×2×2×2×2×2=29One thousand and twenty four1,0242×2×2×2×2×2×2×2×2×2=210In the base ten number system, you used place value tables to identify the value of each digit in a number. The place values were powers of 10.
We can use place value tables in the base two number system as well. The place values are powers of 2. For example:
sixteenseightsfourstwosunits(24)(23)(22)(21)(20)Remember that any number to the power of zero is equal to one. Therefore, 20=1.
To work with binary numbers, you need to be able to write a decimal number as the sum of powers of 2.
Remember that a decimal number is a number that uses the base ten number system. Decimal numbers are the numbers we use in everyday life.
Worked example 3.1: Writing a decimal number as the sum of powers of 2
thirty twossixteenseightsfourstwosunits(25)(24)(23)(22)(21)(20)Write the number 53 as the sum of powers of 2. Then write the number in this base two place value table.
-
Step 1: Find the largest power of 2 that is equal to or smaller than 53.
There is not a power of 2 that is equal to 53.
Try 26. 26=64, so it is bigger than 53 and we can't use it.
The next, smaller power of 2 is 25, and 25=32. So the largest power of 2 that is equal to or smaller than 53 is 25=32.
-
Step 2: Write the given number, 53, as the sum of this power of 2 and what is still left.
53−32=21So written as a sum, we get:
53=32+21 -
Step 3: Now we have to deal with the 21. Find the largest power of 2 that is equal to or smaller than 21.
24=1621−16=5 -
Step 4: Write the given number, 53, as the sum of all of these numbers.
53=32+21=32+16+5 -
Step 5: Now we have to deal with the 5. Find the largest power of 2 that is equal to or smaller than 5.
22=45−4=1 -
Step 6: Write the given number, 53, as the sum of all of these numbers.
53=32+21=32+16+5=32+16+4+1The last number found is 1, so there are no more powers of 2 that we can find.
-
Step 7: Write the sum of powers of 2 in index form.
Remember that 20=1.
53=25+24+22+20 -
Step 8: Put the powers of 2 in a base two place value table.
Where you have a power of 2 in your sum, you write a 1 in the place value table.
Where you do not have a power of 2 in your sum, you write a 0 in the place value table. You do not have a 23 or a 21, so for those place values you write 0.
thirty twossixteenseightsfourstwosunits(25)(24)(23)(22)(21)(20)110101
This means that the decimal (base ten) number 53 written as a binary (base two) number is 110101.
Here is a table with the powers of 2. You can refer back to it as you answer the questions that follow.
20=121=222=423=824=1625=3226=6427=12828=256Exercise 3.1: Write decimal numbers as the sum of powers of 2
Write each decimal number as the sum of powers of 2. Then write the number in a base two place value table.
-
39
39=32+7=32+4+3=32+4+2+1=25+22+21+20
(26)(25)(24)(23)(22)(21)(20)100111 -
75
75=64+11=64+8+3=64+8+2+1=26+23+21+20
(26)(25)(24)(23)(22)(21)(20)1001011 -
120
120=64+56=64+32+24=64+32+16+8=26+25+24+23
(26)(25)(24)(23)(22)(21)(20)1111000 -
228
228=128+100=128+64+36=128+64+32+4=27+26+25+22
(27)(26)(25)(24)(23)(22)(21)(20)11100100 -
277
277=256+21=256+16+5=256+16+4+1=28+24+22+20
(28)(27)(26)(25)(24)(23)(22)(21)(20)100010100
3.3 Binary numbers
The numbers in the base two number system are called binary numbers.
binary numbers The numbers in the base two number system are called binary numbers. They are all represented by combinations of the digits 0 and 1.
We can use a place value table to write the numbers 1 to 16 in the decimal number system as binary numbers:
sixteenseightsfourstwosunitsbinary numberdecimal number(24)(23)(22)(21)(20)11110102111131001004101101511011061111117100010008100110019101010101010111011111100110012110111011311101110141111111115100001000016Notation of decimal and binary numbers
When we work with decimal and binary numbers together, we need a way to identify whether a number is a decimal number or a binary number. For example, the digits 100 represent one hundred objects in the base ten number system, but they represent four objects in the base two number system.
We use subscripts to tell us which system a certain combination of digits belong to. For example:
- 10010 or 100ten means one hundred
- 1002 or 100two means four.
3.4 Converting between decimal and binary numbers
Worked example 3.2: Converting binary numbers to decimal numbers
Write 11010two as a base ten number.
-
Step 1: Draw up a place value table for the powers of 2. Use the number of digits in the given number to help you do this.
The number 110102 has 5 digits. The place value table must have 5 columns.
Start at the right with 20, and count to the left. So this place value table goes up to 24.
sixteenseightsfourstwosunits(24)(23)(22)(21)(20) -
Step 2: Write the given number in the place value table.
sixteenseightsfourstwosunits(24)(23)(22)(21)(20)11010 -
Step 3: Write down the place value of each digit. Add all the values to get the base ten number.
24+23+0+21+0=16+8+2=26∴11010two=26ten
Exercise 3.2: Convert binary numbers to base ten numbers
Convert each of the following binary numbers to base ten numbers.
-
101two
(24)(23)(22)(21)(20)101
4+1=5∴101two=5ten -
1001two
(24)(23)(22)(21)(20)1001
8+1=9∴1001two=9ten -
1111two
(24)(23)(22)(21)(20)1111
8+4+2+1=15∴1111two=15ten -
10011two
(24)(23)(22)(21)(20)10011
16+2+1=19∴10011two=19ten -
11000two
(24)(23)(22)(21)(20)11000
16+8=24∴11000two=24ten -
11110two
(24)(23)(22)(21)(20)11110
16+8+4+2=30∴11110two=30ten -
101001two
(25)(24)(23)(22)(21)(20)101001
32+8+1=41∴101001two=41ten -
111010two
(25)(24)(23)(22)(21)(20)111010
32+16+8+2=58∴111010two=58ten -
1000111two
(26)(25)(24)(23)(22)(21)(20)1000111
64+4+2+1=71∴1000111two=71ten -
1010011two
(26)(25)(24)(23)(22)(21)(20)1010011
64+16+2+1=83∴1010011two=83ten
Worked example 3.3: Converting decimal numbers to binary numbers
Write 23ten as a base two number.
-
Step 1: Divide the given number repeatedly by 2, until you get zero. For each division, write down whether the remainder is 0 or 1.
223211remainder: 125remainder: 122remainder: 121remainder: 00remainder: 1 -
Step 2: Write down the remainders from bottom to top. This gives the corresponding binary number.
10111∴23ten=10111two
If you do not feel comfortable with the method explained here, you can write the decimal number as the sum of powers of 2 and then use a place value table. This is shown in Worked example 3.2.
Exercise 3.3: Convert decimal numbers to base two numbers
Convert each of the following decimal numbers to base two numbers.
Remember that when you write the remainders, you start from the bottom one and go up to the top one.
-
7ten
2723remainder: 121remainder: 10remainder: 1
∴7ten=111two -
11ten
21125remainder: 122remainder: 121remainder: 00remainder: 1
∴11ten=1011two -
13ten
21326remainder: 123remainder: 021remainder: 10remainder: 1
∴13ten=1101two -
20ten
220210remainder: 025remainder: 022remainder: 121remainder: 00remainder: 1
∴20ten=10100two -
29ten
229214remainder: 127remainder: 023remainder: 121remainder: 10remainder: 1
∴29ten=11101two -
36ten
236218remainder: 029remainder: 024remainder: 122remainder: 021remainder: 00remainder: 1
∴36ten=100100two -
44ten
244222remainder: 0211remainder: 025remainder: 122remainder: 121remainder: 00remainder: 1
∴44ten=101100two -
65ten
265232remainder: 1216remainder: 028remainder: 024remainder: 022remainder: 021remainder: 00remainder: 1
∴65ten=1000001two -
78ten
278239remainder: 0219remainder: 129remainder: 124remainder: 122remainder: 021remainder: 00remainder: 1
∴78ten=1001110two -
97ten
297248remainder: 1224remainder: 0212remainder: 026remainder: 023remainder: 021remainder: 10remainder: 1
∴97ten=1100001two
3.5 Summary
- The base two number system is a number system that counts in groups of 2, and uses only the digits 0 and 1 to represent any number.
- In the base ten number system we work with powers of 10. In the base two number system, we work with powers of 2.
- We can use place value tables in the base two number system. The place values are powers of 2. For example:
thirty twossixteenseightsfourstwosunits(25)(24)(23)(22)(21)(20) - The numbers in the base two number system are called binary numbers. They are all represented by combinations of the digits 0 and 1.
- The binary numbers that correspond to the decimal numbers 1 to 10 are:
decimal numberbinary number1121031141005101611071118100091001101010 - We use subscripts to tell us which system a certain combination of digits belong to. For example:
- 10010 or 100ten means one hundred
- 1002 or 100two means four
- We can convert binary numbers to decimal numbers, and decimal numbers to binary numbers.