There
are a number of ways to convert a number in one base (radix) to the equivalent
number in another base. The standard techniques are all variations on three
basic methods. The most straightforward technique is perhaps the expansion
method. Suppose we wish to convert the binary number 10101.1 to decimal. We
may do so merely by using the definition of a number representation as an
abbreviated polynomial, Thus, we may write
10101.1_{2} =1 x 2^{4} + 0 x 2^{3} + 1 x 2^{2} +
0 x 2^{1} + 1 x 2^{0} + 1 x 2^{1}
= 16 + 0 + 4
+ 0 + 1 + 0.5
= 21.5_{10} But
suppose we wish to go the other way. How would we convert 21.5_{10} to
binary? Writing 21.5_{10} = 2 x 10^{1} + 1 x 10^{0} + 5
x 10^{1} does not seem to be of much help. But look at what we get when
we write this polynomial in binary notation (10_{10} = 1010_{2}
and 5_{10} = 101_{2}, of course):
21.5_{10} = (2 x 10^{1} + 1 x 10^{0} + 5 x 10^{1})_{10}
= (10 x 1010^{1}
+ 1 x 1010^{0} + 101 x 1010^{1})_{2}
= (10100 + 1
+ 0.1) _{2}
= 10101.1_{2} The
above examples illustrate an important fact about the conversion techniques that
we will examine—namely, that they may be used to convert from any base to any
other base. This is important to remember, particularly because many texts show
conversion from radixa to radixb being done one way, and
conversion from radixb to radixa being done another, the
implication being that the methods of conversion are fundamentally asymmetric. It is
only fair to concede, however, that the expansion method is easier to use for
converting binary (or, generally, nondecimal) numbers to decimal
representations, than the reverse. The reason for this is that the calculations
that must performed to convert from binary to decimal are done in decimal
arithmetic, but those necessary to convert in the other direction must be
done in binary arithmetic. If we refer to the number system in which the
number to be converted is written as the source number system and the
number system to which we want to convert as the target number system,
then we may say that the expansion method requires the use of target number
system arithmetic. Thus, all things being equal, we are likely to select the
expansion method if we are converting from base7 to base10. Going the other
way, we might look for some other method, one in which we may do the conversion
using the source number system. In fact, the two other conversion methods we
will discuss do use sourcenumbersystem arithmetic. These are the multiplication/division
method and the subtraction method. Let us first consider the
multiplication/division method. Suppose we have a decimal integer we wish to
convert to binary, say, 13_{10}. It is easy to verify that 13_{10}
= 1101_{2}. Now consider the following procedure: Divide the number to
be converted (13) by the target radix (2). The result is an integer quotient (6)
and an integer remainder (1). Repeat the procedure using the quotient in place
of the original dividend. Continue in this fashion until the quotient is 0. The
remainders so generated, when written beside one another make up the binary
representation we desire. The arithmetic is carried out in the source base. In
particular, we have 13 / 2 = 6, r 1
6 / 2 = 3, r 0
3 / 2 = 1, r 1
1 / 2 = 0, r 1 Notice that the
digits of the answer are generated from right to left. The above procedure
appears to work. Why? A hint may be found by looking carefully at the first step
in the example. The number to be converted is either even or odd. If it is even,
the rightmost bit of the binary representation must be 0; if it is odd, that bit
must be 1. (Why?) When an even number is divided by 2, the remainder is 0. When
an odd number is divided by 2, the remainder is 1. We can verify that this
procedure works by looking at it more formally. For nonnegative index i,
let A_{i} be an integer. Let t be our target radix.
Let A_{i+1} be the integer quotient of A_{i}
and t, and let r_{i} be the integer remainder. Then
A_{i} / t = A_{i+1} + r_{i}
/ t Of course, r_{i} is an integer between 0 and t1,
inclusive, as it must be, in the representation of a baset integer. If A_{0}
is the integer to be converted to baset, we may write the following
equivalence, where the baset representation of A_{0} is b_{m}b_{m}_{1}
... b_{1}b_{0}: A_{0}
= b_{m}t^{m} + b_{m}_{1}t^{m}^{1}
+ ... + b_{1}t^{1} + b_{0}t^{0} Consider
the first division. We have: A_{0}
/ t = (b_{m}t^{m} + b_{m}_{1}t^{m}^{1}
+ ... + b_{1}t^{1} + b_{0}t^{0})
/ t
A_{1} + r_{0}
/ t = b_{m}t^{m}^{1} + b_{m}_{1}t^{m}^{2}
+ ... + b_{1} + b_{0} / t But notice that
b_{m}t^{m}^{1} + b_{m}_{1}t^{m}^{2}
+ ... + b_{1} is an integer, and b_{0} / t
is a fraction (i.e., less than 1), since b_{0} < t.
This means we must have A_{1}
= b_{m}t^{m}^{1} + b_{m}_{1}t^{m}^{2}
+ ... + b_{1} and r_{0} = b_{0} Now
suppose this process has been carried out n times, and we have
developed the rightmost n digits of our result, namely, b_{n}_{1}b_{n}_{2}
... b_{0}. Since we have divided the original integer n times,
ignoring remainders), we have A_{n}
= b_{m}t^{m}^{n} + b_{m}_{1}t^{m}^{1n}
+ ... + b_{n} Carrying out the next division gives
A_{n+1} + r_{n} / t = b_{m}t^{m}^{(n+1)}
+ b_{m}_{1}t^{m}^{1(n+1)}
+ ... + b_{+1 }+ b_{n} /
t so that A_{n+1}
= b_{m}t^{m}^{(n+1)} + b_{m}_{1}t^{m}^{1(n+1)}
+ ... + b_{+1 } and r_{n}
= b_{n} This constitutes a recursive proof that the
procedure works. An analogous method is used to convert fractions. In this case,
however, we multiply by the radix (hence, multiplication/division method).
We get our digits from the integer part of any product, and we continue
multiplying using only the fractional part. It is easy to convince yourself that
this procedure works as well. An example is given below. Note that 0.78125_{10}
= 0.11001_{2}. 0.78125 x 2
= 1.56250, digit generated is 1
0.5625 x 2 = 1.1250, digit
generated is 1
0.125 x 2 = 0.250, digit
generated is 0
0.25 x 2 = 0.50, digit generated is 0
0.5 x 2 = 1.0, digit generated
is 1 Here is another example, using the decimal fraction 0.3. It illustrates a
fraction that repeats, in binary, in any case.
0.3 x 2 = 0.6, digit generated is 0
0.6 x 2 = 1.2, digit generated
is 1
0.2 x 2 = 0.4, digit generated
is 0
0.4 x 2 = 0.8, digit generated
is 0
0.8 x 2 = 1.6, digit generated
is 1
0.6 x 2 = 1.2, digit generated
is 1 (repeats second line) Therefore, we have that
0.3_{10} = 0.0100110011001 ... _{2}. Note that we generate digits
from left to right when converting fractions. Generally, digits are generated by
the multiplication/division method from the radix point out. We may summarize
this conversion method as follows:
 Write a target radix point for the answer
 Take the integer (fraction) in source number system and divide
(multiply) by the target radix.
 Write down the remainder (integer) generated to the left (right) of the
last symbol written.
 Is the quotient (fraction) 0? If yes, stop. Otherwise, quotient is new
integer (fraction is new fraction). Go to step 2.
The final fundamental conversion scheme to be examined here is the subtraction
method. In general, it is not a particularly efficient technique. In certain
special situations, however, it is both convenient and intuitively appealing.
Consider the conversion of a decimal integer to another base. For example,
say we wish to convert 16_{10} to base3 notation. We notice that 3^{2}
= 9 is the largest power of 3 less than or equal to 16. We tally 1 and subtract
9 from 16, leaving 7. We now ask if we can subtract 3^{2} again. Since
we cannot, 1 must be out leftmost base3 digit. We now see if we can subtract 3^{1}.
We can—twice, in fact. We do so, and establish 2 as out next base3 digit. We
now have a remainder of 1, from which we can subtract 3^{0} exactly
once. Thus, we find that 16_{10} = 121_{3}. This method is
particularly appealing when converting decimal integers to binary if we remember
the powers of 2. For a conversion to binary, of course, we never have to worry
about subtracting a power of the radix more than once. The subtraction method
may also be used for converting fractions. Notice that, for converting both
integers and fractions, digits in the target representation are generated from
left to right. Notice also that by looking at the problem from a slightly
different angle, the subtraction method could become an addition method.
Instead of subtracting powers of the base, we could construct our result by
adding powers of the base to 0, always attempting to form a sum less than or
equal to the number being converted. The reader can easily work out the details.
In the foregoing discussion, we have illustrated three methods for converting
numbers between bases, any of which, in principle, can be used for any
conversion problem. When working on a particular problem, the conversion method
selected is generally chosen on the basis of the number system in which it is
most convenient to do arithmetic. Usually, we want to avoid arithmetic in
unusual bases (e.g., 7). When doing conversions by hand, then, we try to select
a method that allows the use of decimal arithmetic, though using binary
computation is sometimes convenient. Conversions between inconvenient bases
usually require an intermediate conversion. Converting from base5 to base7,
for example, one might first convert to base10. The table below provides a
guide to selecting a conversion method:
CONVERSION METHOD 
BASE ARITHMETIC USED 
Expansion 
Target 
Multiplication/Division 
Source 
Subtraction 
Source 
Exercises
 Convert 26.625_{10} to binary using the three methods discussed
above.
 Convert 100100.001_{2} to decimal using the three methods
discussed.
 Convert 2569_{10} to base9 notation.
 Convert 2761_{9} to base5 notation.
 One method of converting binary integers to decimal integers is the multiply
and add method. In this scheme, the leftmost digit is multiplied by 2
and added to the digit to its right. That sum is then multiplied by 2 and
added to the next digit to the right, and so forth. Explain why this system
works. Of what technique is it a variation? Can you convert fractions in an analogous
way?
