The Binary Number System
The Binary Number System
Our civilization uses the base 10 or decimal place value system. Each digit in a number
represents a power of 10. For example, 365.42 means
There is nothing sacred about base 10. We could just as well use base 2, also called
binary.
... __ __ __ __ . __ __ ...
23 22 21 20 21 22
That is, 1101.12 = 13.510, where the subscript indicates the base.
In general, to convert binary to decimal, just expand out using place values. Try
converting 10110102 to base 10. Did you get 90?
To convert a base 10 integer to binary, think of filling in blanks in the binary place value
chart, starting as far left as possible. That is, pull out the largest power of 2 possible
from the integer. Subtract it from the original number, and repeat with the remainder.
Continue until the remainder is 0 or 1.
Solution: 64 ( = 26) is the largest power of 2 that is less than or equal to 85. Put 1 in
the 64’s place and subtract it off.
1
85 – 64 = 21
26 25 24 23 22 21 20
Repeat, this time using 21. The largest power of 2 less than or equal to 21 is 16 (=23).
Put 1 in the 16’s position and subtract it off. Note that this also requires us to put 0 in
the 32’s position!
1 0 1
21 – 16 = 5
26 25 24 23 22 21 20
1 0 1 0 1
5–4=1
26 25 24 23 22 21 20
Since the remainder is 1, put 1 in the 1’s position (and 0 in the 2’s position).
1 0 1 0 1 0 1
26 25 24 23 22 21 20
Try counting in binary, starting with 0. Do you get 0, 1, 10, 11, 100, 101, 110, 111,
1000, …?
With that assumption, write the integer numerator in binary, write the denominator as a
power of 2, and shift the binary point left the number of places indicated by the
exponent.
5
Example: Convert to binary.
8
Solution: First, 510 = 4 + 1 = 1012. Since 8 = 23, shift the binary point three places to
5 5
the left. 3 .1012
8 2
Convert a mixed base 10 number to base 2 by writing the mixed number as an improper
fraction and proceeding as above.
Just as we use base 10 and base 2 place values, we could use other bases. In particular,
base 16, also called hexadecimal, is used frequently in computer science.
... __ __ __ __ . __ __ ...
163 162 161 160 161 162
Since 162 = 256, 163 = 4096, and so on, hexadecimal place values increase rapidly!
= 256 + 80 + 8
= 34410
= 2*256 + 8*16 + 3
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ?
What should be the tenth positive integer? It cannot be written as 10, because
We must have another symbol for the tenth digit. A little thought should convince you
that we need symbols for the eleventh through the fifteenth digit, too. This will give 16
digits in all, including 0. As a general principle, base n requires n digits, including 0.
Each digit must be a single symbol. The common agreement in mathematics is to use the
letters A, B, C, D, E, and F as the new symbols.
Base 8 digits: 0, 1, 2, 3, 4, 5, 6, 7
Base 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Use the extended set of digits as needed to convert decimal to base 16.
= 1*256 + 11*16 + 13
Converting between base 16 and base 2 is particularly useful. You can do this by going
through base 10, of course, but it is much quicker to convert directly. Since 16 = 24, one
hexadecimal digit is the equivalent of four binary digits. To convert from base 2 to base
16, just group the base 2 bits by fours, starting on the right. Convert each group of four
bits to its equivalent digit in base 16.
Solution: Group the bits by fours, starting on the right. For emphasis, write two leading
zeros to round out the first group of bits.
Now 00102 = 216, 11012 = 1310 = D16, and 10012 = 916 , so 10110110012 = 2D916 .
a. 10110
b. 11100111
c. 101.011
a. 86
b. 131
5
c. 14
8
a. 68
b. 543
c. 127
a. 10D
b. 345
c. BABE
a. 53
b. 94B0
c. 3ED
a. 1010 0101
b. 0011 0000 1101 1111
c. 1001 0111 0110 1000
a. binary
b. hexadecimal
a. binary
b. base 10