Binary Conversion
Binary Conversion
The inner parentheses around 1 5 are not needed since the product would be au-
tomatically 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
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, mul-
tiply again by the base, and so on. The last step is to add the last digit
Yin-yang The binary (base two) on the right. Do not multiply it by the base.
symbols of the I Ching, a 2000-
year-old Chinese classic, permute
into 8 elemental trigrams; 64 Exactly how you accomplish these steps depends on the type of calculator you
hexagrams are interpreted in
use. With some, only the digits, the multiplications, and the additions need to be en-
casting oracles.
tered, in order. With others, you may need to press the key following each addi-
The basic symbol here is the
ancient Chinese “yin-yang,” in
tion of a digit. If you handle grouped expressions on your calculator by actually
which the black and the white entering parentheses, then enter the expression just as illustrated above and in the
enfold each other, each containing following example. (The number of left parentheses to start with will be two fewer
a part of the other. A kind of than the number of digits in the original numeral.)
duality is conveyed between
destructive (yin) and beneficial EXAMPLE 2 Use the calculator shortcut to convert 244314 five to deci-
(yang) aspects. Leibniz mal form.
(1646 –1716) studied Chinese
ideograms in search of a universal 244314 five 2 5 4 5 4 5 3 5 1 5 4
symbolic language and promoted 9334
East-West cultural contact. He saw
parallels between the trigrams and EXAMPLE 3 Convert 497 from decimal form to base five.
his binary arithmetic.
The base five place values, starting from the right, are 1, 5, 25, 125, 625, and
Niels Bohr (1885 –1962),
so on. Since 497 is between 125 and 625, it will require no 625s, but some 125s, as
famous Danish Nobel laureate in
physics (atomic theory), adopted
well as possibly some 25s, 5s, and 1s. Dividing 497 by 125 determines the proper
the yin-yang symbol in his coat of number of 125s. The quotient is 3, with remainder 122. So we need three 125s. Next,
arms to depict his principle of the remainder, 122, is divided by 25 (the next place value) to find the proper num-
complementarity, which he ber of 25s. The quotient is 4, with remainder 22, so we need four 25s. Dividing 22
believed was fundamental to by 5 yields 4, with remainder 2. So we need four 5s. Dividing 2 by 1 yields 2 (with
reality at the deepest levels. Bohr remainder 0), so we need two 1s. Finally, we see that 497 consists of three 125s, four
also pushed for East-West 25s, four 5s, and two 1s, so 497 3442 five .
cooperation. More concisely, this process can be written as follows.
In its 1992 edition, The World
Book Dictionary first judged “yin- 497 125 3 Remainder 122
yang” to have been used enough
122 25 4 Remainder 22
to become a permanent part of our
ever changing language, assigning 22 5 4 Remainder 2
it the definition, “made up of 212 Remainder 0
opposites.”
497 3442 five
The calculator shortcut for converting from another base to decimal form in-
volved 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 2
5 19 4
5 3 4
0 3
Read the answer from the remainder column, reading from the bottom up:
Woven fabric is a binary To see why this shortcut works, notice the following:
system of threads going
lengthwise (warp threads — tan in The first division shows that four hundred ninety-seven 1s are equivalent to
the diagram above) and threads ninety-nine 5s and two 1s. (The two 1s are set aside and account for the last
going crosswise (weft or woof). At digit of the answer.)
any point in a fabric, either warp
or weft is on top, and the variation The second division shows that ninety-nine 5s are equivalent to nineteen 25s
creates the pattern. and four 5s. (The four 5s account for the next digit of the answer.)
Nineteenth-century looms for
weaving operated using punched
The third division shows that nineteen 25s are equivalent to three 125s and
cards, “programmed” for pattern. four 25s. (The four 25s account for the next digit of the answer.)
The looms were set up with
The fourth (and final) division shows that the three 125s are equivalent to no
hooked needles, the hooks holding
625s and three 125s. The remainders, as they are obtained from top to bottom,
the warp. Where there were holes
in cards, the needles moved, the
give the number of 1s, then 5s, then 25s, then 125s.
warp lifted, and the weft passed
under. Where no holes were, the
The methods for converting between bases ten and five, including the shortcuts,
warp did not lift, and the weft was can be adapted for conversions between base ten and any other base.
on top. The system parallels the
on-off system in calculators and EXAMPLE 5 Convert 6343 seven to decimal form, by expanding in powers,
computers. In fact, these looms and by using the calculator shortcut.
were models in the development of
modern calculating machinery. 6343 seven 6 73 3 72 4 71 3 70
Joseph Marie Jacquard 6 343 3 49 4 7 3 1
(1752 –1823) is credited with
2058 147 28 3
improving the mechanical loom
so that mass production of fabric 2236
was feasible.
Calculator shortcut: 6343 seven 6 7 3 7 4 7 3 2236 .
7 7508
7 1072 4
7 153 1
7 21 6
7 3 0
0 3
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.
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.
Hexadecimal
Remainder notation
16 748
16 46 12 C
16 2 14 E
0 2 2
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). Con-
versions among binary, octal, and hexadecimal systems can generally be accom-
plished by the shortcuts explained below, and are illustrated in the next several
examples.
0 0 0 0
1 1 1 1
2 2 2 10
3 3 3 11
4 4 4 100
5 5 5 101
6 6 6 110
7 7 7 111
8 8 10 1000
9 9 11 1001
10 A 12 1010
11 B 13 1011
12 C 14 1100
13 D 15 1101
14 E 16 1110
15 F 17 1111
16 10 20 10000
17 11 21 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 rel-
atively small numbers. The octal and hexadecimal systems are the choices of com-
puter programmers mainly because of their close relationship with the binary
system. Both eight and sixteen are powers of two. When conversions involve one
base that is a power of the other, there is a quick conversion shortcut available. For
TABLE 7
example, since 8 23, every octal digit (0 through 7) can be expressed as a 3-digit
Octal Binary binary numeral. See Table 7.
0 000
1 001
2 010
E X A M P L E 12 Convert 473 eight to binary form.
3 011 Replace each octal digit with its 3-digit binary equivalent. (Leading zeros can
4 100 be omitted only when they occur in the leftmost group.) Then combine all the binary
5 101 equivalents into a single binary numeral.
6 110
7 111 4 7 3 eight
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.)
8 B 4 Fsixteen
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 B C D E
Several years ago, the Kellogg 1 2 4 8 16
Company featured a Magic Trick 3 3 5 9 17
Age Detector activity on specially 5 6 6 10 18
marked packages of Kellogg’s ® 7 7 7 11 19
Rice Krispies ® cereal. The trick 9 10 12 12 20
is simply an extension of the 11 11 13 13 21
discussion in the text. 13 14 14 14 22
15 15 15 15 23
Kellogg’s ® Rice Krispies ® and 17 18 20 24 24
characters Snap! ® Crackle! ® 19 19 21 25 25
and Pop! ® are registered 21 22 22 26 26
trademarks of Kellogg Company. 23 23 23 27 27
25 26 28 28 28
27 27 29 29 29
29 30 30 30 30
31 31 31 31 31