Top-Rated Free Essay

Conversion between Number Bases

Good Essays
4.3

4.3

Conversion Between Number Bases

169

Conversion Between Number Bases
Although the numeration systems discussed in the opening section were all base ten, other bases have occurred historically. For example, the ancient Babylonians used 60 as their base. The Mayan Indians of Central America and Mexico used 20. In this section we consider bases other than ten, but we use the familiar HinduArabic symbols. We will consistently indicate bases other than ten with a spelled-out subscript, as in the numeral 43 five . Whenever a number appears without a subscript, it is to be assumed that the intended base is ten. It will help to be careful how you read (or verbalize) numerals here. The numeral 43 five is read “four three base five.”
(Do not read it as “forty-three,” as that terminology implies base ten and names a totally different number.)
For reference in doing number expansions and base conversions, Table 3 gives the first several powers of some numbers used as alternative bases in this section.
TABLE 3

Selected Powers of Some Alternative Number Bases
Fourth
Power

TABLE 4
Base Ten

Base Five

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

0
1
2
3
4
10
11
12
13
14
20
21
22
23
24
30
31
32
33
34
40
41
42
43
44
100
101
102
103
104
110

Base two
Base five
Base seven
Base eight
Base sixteen

Third
Power

Second
Power

First
Power

Zero
Power

16
625
2401
4096
65,536

8
125
343
512
4096

4
25
49
64
256

2
5
7
8
16

1
1
1
1
1

We begin with the base five system, which requires just five distinct symbols,
0, 1, 2, 3, and 4. Table 4 compares base five and decimal (base ten) numerals for the whole numbers 0 through 30. Notice that, while the base five system uses fewer distinct symbols, it sometimes requires more digits to denote the same number.
EXAMPLE 1
Convert 1342 five to decimal form.
Referring to the powers of five in Table 3, we see that this number has one 125, three 25s, four 5s, and two 1s, so
1342 five ෇ ͑1 ϫ 125͒ ϩ ͑3 ϫ 25͒ ϩ ͑4 ϫ 5͒ ϩ ͑2 ϫ 1͒
෇ 125 ϩ 75 ϩ 20 ϩ 2
෇ 222 .



A shortcut for converting from base five to decimal form, which is particularly useful when you use a calculator, can be derived as follows. (We can illustrate this by repeating the conversion of Example 1.)
1342 five ෇ ͑1 ϫ 53͒ ϩ ͑3 ϫ 52͒ ϩ ͑4 ϫ 5͒ ϩ 2
Now 5 can be factored out of the three quantities in parentheses, so
1342 five ෇ ͑͑1 ϫ 52͒ ϩ ͑3 ϫ 5͒ ϩ 4͒ ϫ 5 ϩ 2 .
Now, factoring another five out of the two “inner” quantities, we get
1342 five ෇ ͑͑͑1 ϫ 5͒ ϩ 3͒ ϫ 5 ϩ 4͒ ϫ 5 ϩ 2 .

An Addison-Wesley product. Copyright © 2004 Pearson Education, Inc.

170

CHAPTER 4

Numeration and Mathematical Systems

The inner parentheses around 1 ϫ 5 are not needed since the product would be automatically done before the 3 is added. Therefore, we can write
1342 five ෇ ͑͑1 ϫ 5 ϩ 3͒ ϫ 5 ϩ 4͒ ϫ 5 ϩ 2 .
This series of products and sums is easily done as an uninterrupted sequence of operations on a calculator, with no intermediate results written down. The same method works for converting to base ten from any other base. The procedure is summarized as follows.

Calculator Shortcut

Yin-yang The binary (base two) symbols of the I Ching, a 2000year-old Chinese classic, permute into 8 elemental trigrams; 64 hexagrams are interpreted in casting oracles.
The basic symbol here is the ancient Chinese “yin-yang,” in which the black and the white enfold each other, each containing a part of the other. A kind of duality is conveyed between destructive (yin) and beneficial
(yang) aspects. Leibniz
(1646 –1716) studied Chinese ideograms in search of a universal symbolic language and promoted
East-West cultural contact. He saw parallels between the trigrams and his binary arithmetic.
Niels Bohr (1885 –1962), famous Danish Nobel laureate in physics (atomic theory), adopted the yin-yang symbol in his coat of arms to depict his principle of complementarity, which he believed was fundamental to reality at the deepest levels. Bohr also pushed for East-West cooperation. In its 1992 edition, The World
Book Dictionary first judged “yinyang” to have been used enough to become a permanent part of our ever changing language, assigning it the definition, “made up of opposites.” To convert from another base to decimal form: Start with the first digit on the left and multiply by the base. Then add the next digit, multiply again by the base, and so on. The last step is to add the last digit on the right. Do not multiply it by the base.

Exactly how you accomplish these steps depends on the type of calculator you use. With some, only the digits, the multiplications, and the additions need to be entered, in order. With others, you may need to press the ϭ key following each addition of a digit. If you handle grouped expressions on your calculator by actually entering parentheses, then enter the expression just as illustrated above and in the following example. (The number of left parentheses to start with will be two fewer than the number of digits in the original numeral.)
EXAMPLE
mal form.

2

Use the calculator shortcut to convert 244314 five to deci-

244314 five ෇ ͑͑͑͑2 ϫ 5 ϩ 4͒ ϫ 5 ϩ 4͒ ϫ 5 ϩ 3͒ ϫ 5 ϩ 1͒ ϫ 5 ϩ 4
෇ 9334



EXAMPLE 3
Convert 497 from decimal form to base five.
The base five place values, starting from the right, are 1, 5, 25, 125, 625, and so on. Since 497 is between 125 and 625, it will require no 625s, but some 125s, as well as possibly some 25s, 5s, and 1s. Dividing 497 by 125 determines the proper number of 125s. The quotient is 3, with remainder 122. So we need three 125s. Next, the remainder, 122, is divided by 25 (the next place value) to find the proper number of 25s. The quotient is 4, with remainder 22, so we need four 25s. Dividing 22 by 5 yields 4, with remainder 2. So we need four 5s. Dividing 2 by 1 yields 2 (with remainder 0), so we need two 1s. Finally, we see that 497 consists of three 125s, four
25s, four 5s, and two 1s, so 497 ෇ 3442 five .
More concisely, this process can be written as follows.
497 Ϭ 125 ෇ 3
122 Ϭ 25 ෇ 4
22 Ϭ 5 ෇ 4
2Ϭ1෇2
497 ෇ 3442 five

Remainder 122
Remainder 22
Remainder 2
Remainder 0

An Addison-Wesley product. Copyright © 2004 Pearson Education, Inc.

4.3 Conversion Between Number Bases

171

3442 five ෇ ͑3 ϫ 125͒ ϩ ͑4 ϫ 25͒ ϩ ͑4 ϫ 5͒ ϩ ͑2 ϫ 1͒
෇ 375 ϩ 100 ϩ 20 ϩ 2
෇ 497 .

Check:



The calculator shortcut for converting from another base to decimal form involved repeated multiplications by the other base. (See Example 2.) A shortcut for converting from decimal form to another base makes use of repeated divisions by the other base. Just divide the original decimal numeral, and the resulting quotients in turn, by the desired base until the quotient 0 appears.
Photo not available

EXAMPLE

4

Repeat Example 3 using the shortcut just described.
Remainder

5 ͉ 497
5 ͉ 99
5 ͉ 19
5͉ 3
0

2
4
4
3

Read the answer from the remainder column, reading from the bottom up:
497 ෇ 3442 five .
Woven fabric is a binary system of threads going lengthwise (warp threads — tan in the diagram above) and threads going crosswise (weft or woof). At any point in a fabric, either warp or weft is on top, and the variation creates the pattern.
Nineteenth-century looms for weaving operated using punched cards, “programmed” for pattern.
The looms were set up with hooked needles, the hooks holding the warp. Where there were holes in cards, the needles moved, the warp lifted, and the weft passed under. Where no holes were, the warp did not lift, and the weft was on top. The system parallels the on-off system in calculators and computers. In fact, these looms were models in the development of modern calculating machinery.
Joseph Marie Jacquard
(1752 –1823) is credited with improving the mechanical loom so that mass production of fabric was feasible.



To see why this shortcut works, notice the following:
The first division shows that four hundred ninety-seven 1s are equivalent to ninety-nine 5s and two 1s. (The two 1s are set aside and account for the last digit of the answer.)
The second division shows that ninety-nine 5s are equivalent to nineteen 25s and four 5s. (The four 5s account for the next digit of the answer.)
The third division shows that nineteen 25s are equivalent to three 125s and four 25s. (The four 25s account for the next digit of the answer.)
The fourth (and final) division shows that the three 125s are equivalent to no
625s and three 125s. The remainders, as they are obtained from top to bottom, give the number of 1s, then 5s, then 25s, then 125s.
The methods for converting between bases ten and five, including the shortcuts, can be adapted for conversions between base ten and any other base.
EXAMPLE 5
Convert 6343 seven to decimal form, by expanding in powers, and by using the calculator shortcut.
6343 seven ෇ ͑6 ϫ 73͒ ϩ ͑3 ϫ 72͒ ϩ ͑4 ϫ 71͒ ϩ ͑3 ϫ 70͒
෇ ͑6 ϫ 343͒ ϩ ͑3 ϫ 49͒ ϩ ͑4 ϫ 7͒ ϩ ͑3 ϫ 1͒
෇ 2058 ϩ 147 ϩ 28 ϩ 3
෇ 2236
Calculator shortcut: 6343 seven ෇ ͑͑6 ϫ 7 ϩ 3͒ ϫ 7 ϩ 4͒ ϫ 7 ϩ 3 ෇ 2236 .

An Addison-Wesley product. Copyright © 2004 Pearson Education, Inc.



172

CHAPTER 4

Numeration and Mathematical Systems

EXAMPLE 6
Convert 7508 to base seven.
Divide 7508 by 7, then divide the resulting quotient by 7, and so on, until a quotient of 0 results.
Remainder

7 ͉ 7508
7 ͉1072
7 ͉ 153
7 ͉ 21
7͉ 3
0

4

1
6
0
3

From the remainders, reading bottom to top, 7508 ෇ 30614 seven .



Because we are accustomed to doing arithmetic in base ten, most of us would handle conversions between arbitrary bases (where neither is ten) by going from the given base to base ten and then to the desired base, as illustrated in the next example.
EXAMPLE 7
Convert 3164 seven to base five.
First convert to decimal form.
3164 seven ෇ ͑3 ϫ 73͒ ϩ ͑1 ϫ 72͒ ϩ ͑6 ϫ 71͒ ϩ ͑4 ϫ 70͒
෇ ͑3 ϫ 343͒ ϩ ͑1 ϫ 49͒ ϩ ͑6 ϫ 7͒ ϩ ͑4 ϫ 1͒
෇ 1029 ϩ 49 ϩ 42 ϩ 4
෇ 1124
Next convert this decimal result to base five.
Remainder

TABLE 5
Base Ten
(decimal)

Base Two
(binary)

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
10000
10001
10010
10011
10100

5 ͉ 1124
5 ͉ 224
5 ͉ 44
5͉ 8
5͉ 1
0

4

4
4
3
1

From the remainders, 3164 seven ෇ 13444 five .

Computer Mathematics



There are three alternative base systems that are most useful in computer applications. These are the binary (base two), octal (base eight), and hexadecimal (base sixteen) systems. Computers and handheld calculators actually use the binary system for their internal calculations since that system consists of only two symbols, 0 and 1. All numbers can then be represented by electronic “switches,” of one kind or another, where “on” indicates 1 and “off” indicates
0. The octal system is used extensively by programmers who work with internal computer codes. In a computer, the CPU (central processing unit) often uses the hexadecimal system to communicate with a printer or other output device.
The binary system is extreme in that it has only two available symbols (0 and
1); because of this, representing numbers in binary form requires more digits than in any other base. Table 5 shows the whole numbers up to 20 expressed in binary form.

An Addison-Wesley product. Copyright © 2004 Pearson Education, Inc.

4.3

Conversion Between Number Bases

173

Conversions between any of these three special base systems (binary, octal, and hexadecimal) and the decimal system can be done by the methods already discussed, including the shortcut methods.
EXAMPLE 8
Convert 110101 two to decimal form, by expanding in powers, and by using the calculator shortcut.
110101 two ෇ ͑1 ϫ 25͒ ϩ ͑1 ϫ 24͒ ϩ ͑0 ϫ 23͒ ϩ ͑1 ϫ 22͒ ϩ ͑0 ϫ 21͒ ϩ ͑1 ϫ 20͒
෇ ͑1 ϫ 32͒ ϩ ͑1 ϫ 16͒ ϩ ͑0 ϫ 8͒ ϩ ͑1 ϫ 4͒ ϩ ͑0 ϫ 2͒ ϩ ͑1 ϫ 1͒
෇ 32 ϩ 16 ϩ 0 ϩ 4 ϩ 0 ϩ 1
෇ 53
Calculator shortcut:
110101 two ෇ ͑͑͑͑1 ϫ 2 ϩ 1͒ ϫ 2 ϩ 0͒ ϫ 2 ϩ 1͒ ϫ 2 ϩ 0͒ ϫ 2 ϩ 1
෇ 53 .



Trick or Tree? The octal number 31 is equal to the decimal number 25. This may be written as

EXAMPLE 9
Convert 9583 to octal form.
Divide repeatedly by 8, writing the remainders at the side.

31 OCT ෇ 25 DEC

8 ͉ 9583
8 ͉1197
8 ͉ 149
8 ͉ 18
8͉ 2
0

Does this mean that Halloween and Christmas fall on the same day of the year?

Remainder

7

5
5
2
2

From the remainders, 9583 ෇ 22557eight .



The hexadecimal system, having base 16, which is greater than 10, presents a new problem. Since distinct symbols are needed for all whole numbers from 0 up to one less than the base, base sixteen requires more symbols than are normally used in our decimal system. Computer programmers commonly use the letters A,
B, C, D, E, and F as hexadecimal digits for the numbers ten through fifteen, respectively. Converting Calculators A number of scientific calculators are available that will convert between decimal, binary, octal, and hexadecimal, and will also do calculations directly in all of these separate modes.

E X A M P L E 10 Convert FA5 sixteen to decimal form.
Since the hexadecimal digits F and A represent 15 and 10, respectively,
FA5 sixteen ෇ ͑15 ϫ 162͒ ϩ ͑10 ϫ 161͒ ϩ ͑5 ϫ 160͒
෇ 3840 ϩ 160 ϩ 5
෇ 4005 .

An Addison-Wesley product. Copyright © 2004 Pearson Education, Inc.



174

CHAPTER 4

Numeration and Mathematical Systems

E X A M P L E 11 Convert 748 from decimal form to hexadecimal form.
Use repeated division by 16.
Remainder

Hexadecimal notation 12
14
2

C
E
2

16 ͉ 748
16 ͉ 46
16 ͉ 2
0

From the remainders at the right, 748 ෇ 2EC sixteen .



The decimal whole numbers 0 through 17 are shown in Table 6 along with their equivalents in the common computer-oriented bases (two, eight, and sixteen). Conversions among binary, octal, and hexadecimal systems can generally be accomplished by the shortcuts explained below, and are illustrated in the next several examples. TABLE 6

Some Decimal Equivalents in the Common
Computer-Oriented Bases

Decimal
(Base Ten)

Hexadecimal
(Base Sixteen)

Octal
(Base Eight)

Binary
(Base Two)

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10
11

0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
20
21

0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
10000
10001

The binary system is the natural one for internal computer workings because of its compatibility with the two-state electronic switches. It is very cumbersome, however, for human use, because so many digits occur even in the numerals for relatively small numbers. The octal and hexadecimal systems are the choices of computer programmers mainly because of their close relationship with the binary system. Both eight and sixteen are powers of two. When conversions involve one

An Addison-Wesley product. Copyright © 2004 Pearson Education, Inc.

4.3

TABLE 7
Octal

Binary

0
1
2
3
4
5
6
7

000
001
010
011
100
101
110
111

Conversion Between Number Bases

175

base that is a power of the other, there is a quick conversion shortcut available. For example, since 8 ෇ 23, every octal digit (0 through 7) can be expressed as a 3-digit binary numeral. See Table 7.

E X A M P L E 12 Convert 473 eight to binary form.
Replace each octal digit with its 3-digit binary equivalent. (Leading zeros can be omitted only when they occur in the leftmost group.) Then combine all the binary equivalents into a single binary numeral.
4

7

3 eight

100

111

011 two

By this method, 473 eight ෇ 100111011 two .



Convert from binary form to octal form in a similar way. Start at the right and break the binary numeral into groups of three digits. (Leading zeros in the leftmost group may be omitted.)

TABLE 8
Hexadecimal

Binary

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F

0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111

E X A M P L E 13 Convert 10011110 two to octal form.
Starting at the right, break the digits into groups of three. Then convert the groups to their octal equivalents.
10

011

110 two

2

3

6 eight

Finally, 10011110 two ෇ 236 eight .



Since 16 ෇ 24, every hexadecimal digit can be equated to a 4-digit binary numeral (see Table 8), and conversions between binary and hexadecimal forms can be done in a manner similar to that used in Examples 12 and 13.

E X A M P L E 14 Convert 8B4Fsixteen to binary form.
Each hexadecimal digit yields a 4-digit binary equivalent.
8

B

4

Fsixteen

1000

1011

0100

1111 two

Combining these groups of digits, we see that
8B4Fsixteen ෇ 1000101101001111 two .

An Addison-Wesley product. Copyright © 2004 Pearson Education, Inc.



176

CHAPTER 4

Numeration and Mathematical Systems

Several games and tricks are based on the binary system. For example, Table 9 can be used to find the age of a person 31 years old or younger. The person need only tell you the columns that contain his or her age. For example, suppose Kellen Dawson says that her age appears in columns B and D only. To find her age, add the numbers from the top row of these columns:
Kellen is 2 ϩ 8 ෇ 10 years old.
Do you see how this trick works? (See Exercises 68–71.)

TABLE 9
A
Several years ago, the Kellogg
Company featured a Magic Trick
Age Detector activity on specially marked packages of Kellogg’s ®
Rice Krispies ® cereal. The trick is simply an extension of the discussion in the text.
Kellogg’s ® Rice Krispies ® and characters Snap! ® Crackle! ® and Pop! ® are registered trademarks of Kellogg Company.

B

C

D

E

1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31

2
3
6
7
10
11
14
15
18
19
22
23
26
27
30
31

4
5
6
7
12
13
14
15
20
21
22
23
28
29
30
31

8
9
10
11
12
13
14
15
24
25
26
27
28
29
30
31

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

An Addison-Wesley product. Copyright © 2004 Pearson Education, Inc.

You May Also Find These Documents Helpful