Chapter 2/2.8Accelerateabout 10 min
Number bases and binary
Suppose humans had only five fingers in total, and counted in groups of five instead of ten. Count 13 stones by putting them into piles of five. How many full piles are there, and how many stones are left over? How might you write that as a two digit number?
Thirteen stones make 2 piles of five and 3 left over. In a base five system we would write this as 23, meaning 2 fives and 3 ones. To avoid confusing it with our twenty three, we write the base as a small number below: 235.
base The base of a number system is the number of units in one place that are exchanged for one unit in the next place to the left. In base 10 the places are worth 1, 10, 100, 1,000, .... In base 5 they are worth 1, 5, 25, 125, .... For example, in base 5 the digits 23 mean 2 × 5 + 3 = 13.
In base 5 the only digits needed are 0, 1, 2, 3 and 4, since five of anything is exchanged for one of the next place. In base 10 we need ten digits, 0 to 9.
Changing from base 5 to base 10. Multiply each digit by its place value and add.
Convert 14325 to base 10.
Changing from base 10 to base 5. Divide by 5 again and again, writing down the remainders. Read the remainders from the last to the first.
Write 242 in base 5.
Why it works. The first division splits 242 stones into 48 piles of 5 with 2 left over: the 2 is the ones digit. Then the 48 piles are grouped in fives: 9 groups of 25 with 3 piles of 5 left over: the 3 is the fives digit. And so on up the places. Each remainder is what cannot be exchanged into the next place.
Binary. The smallest base that works is base 2, called binary. Its places are worth 1, 2, 4, 8, 16, 32, 64, ..., each double the one before, and the only digits are 0 and 1.
binary Binary is the base 2 number system. It uses only the digits 0 and 1, and its places are worth 1, 2, 4, 8, 16 and so on. For example, the binary number 1101 means 8 + 4 + 1 = 13.
- (a)Convert 1011012 to base 10.
- (b)Write 50 in binary.
Why computers use binary. A computer chip contains billions of tiny electronic switches. Each switch is either off or on, which can stand for 0 or 1. It is much easier to build a switch that reliably tells "off" from "on" than one that reliably tells apart ten different levels. So everything a computer stores is binary: numbers, letters, photos and music. In a common code, the capital letter A is stored as 65, which is 10000012. When you write programs at Emzini weCode, every line you type is turned into long strings of 0s and 1s before the machine can follow it. The German mathematician Gottfried Wilhelm Leibniz described binary arithmetic in detail around 1700, more than two hundred years before the first electronic computers.
Solving Gogo MaNcube's problem. Now return to the market scale. Suppose Gogo MaNcube buys weights of 1, 2, 4, 8, 16 and 32 kg. To weigh 45 kg she writes 45 in binary: 1011012. The 1s tell her which weights to use: 32 + 8 + 4 + 1 = 45. Every whole number from 1 to 63 can be written in binary with at most six digits (63 = 1111112 = 32 + 16 + 8 + 4 + 2 + 1), so every target can be weighed. Six weights are enough.
Could fewer weights work? With five weights, each weight is either in the pan or not, which gives 2 × 2 × 2 × 2 × 2 = 32 choices. One of those choices is "no weights at all", which weighs nothing. That leaves at most 31 different amounts, but she needs 63. So five weights can never be enough, whatever their sizes. Six weights is the smallest number, and 1, 2, 4, 8, 16, 32 kg works. (In fact these are the only six weights that work, but that takes more proof.)
Weights in both pans. If Gogo MaNcube is allowed to put weights in the same pan as the maize meal, she can do even better. With weights of 1, 3, 9 and 27 kg she can weigh every whole number from 1 kg to 40 kg. For example, to weigh 5 kg she puts 9 kg in one pan and 3 kg and 1 kg with the maize meal: 9 − 3 − 1 = 5. Each weight now has three choices (left pan, right pan, or unused), and this leads to a system called balanced base 3.
Reading a binary number as a base ten number. The binary number 1000 is not one thousand. It is 8.
Check your understanding 2.8
- Convert to base 10:
- (a)345
- (b)20135
- (c)110112
- (d)10000002
Show answerHide answer
- (a)3 × 5 + 4 = 19
- (b)2 × 125 + 0 + 5 + 3 = 258
- (c)16 + 8 + 2 + 1 = 27
- (d)64
- Write in base 5:
- (a)19
- (b)130
Show answerHide answer
- (a)345
- (b)130 = 1 × 125 + 0 × 25 + 1 × 5 + 0, so 10105
- Write in binary:
- (a)13
- (b)37
- (c)100
Show answerHide answer
- (a)11012
- (b)1001012
- (c)11001002
- Which weights from 1, 2, 4, 8, 16 and 32 kg does Gogo MaNcube use for 27 kg? For 60 kg?
Show answerHide answer
27 = 110112: 16, 8, 2 and 1 kg. 60 = 1111002: 32, 16, 8 and 4 kg.
