You are on page 1of 2

Glad it helped. Here's some additional info.

It does not work for 5 and 20 but it does work for 4 and 16. If you
have a number like 12132 in base 4, you group the digits in pairs from
the right, as "01 21 32" and rewrite converting each of those 2-digit
base 4 numbers to one base-16 digit, giving 19E in hexadecimal.

Perhaps you don't see right off why we take pairs in this situation
and groups of 3 in the other. Here is why it works. It is all related
to the Distributive Law, which says that for any 3 numbers x, y, and
z, (x + y)*z = x*z + y*z. That is how you "multiply out" if you go
from the left side to the right side. If you have something like what
is on the right side, this tells you how to "factor out" the z. Let's
use that. The base 4 number 12132 stands for the base 10 expression

1*4^4 + 2*4^3 + 1*4^2 + 3*4^1 + 2*4^0

where the "^" indicates a power or exponent. Since 4^1 is just 4 and
4^0 is 1, this can also be written as

1*4^4 + 2*4^3 + 1*4^2 + 3*4 + 2

Now, to make the next step clearer, I'll add some parentheses to focus
attention on parts of the expression.

1*4^4 + (2*4^3 + 1*4^2) + (3*4 + 2)

Here is a clue as to where we are heading. All this is in terms of


powers of 4. That makes sense, because it is in base 4. But if we want
to convert to base 16, we want to have things in terms of powers of
16. So, what I am going to do is to convert the powers of 4 to powers
of 16 as much as possible. I will do one very small step here first,
so you can see the kind of thing I'm up to.

1*4^4 + (2*4*16 + 1*16) + (3*4 + 2)

It's important that you understand why this change gives an equivalent
expression. (Also, this shows why the method works only when the
larger base is a power of the smaller base, as 8 is a power of 2 for
the original example, and 16 is a power of 4 in this example.) Now we
factor out the 16 to get another equivalent expression.

1*4^4 + (2*4 + 1)*16 + (3*4 + 2)

Next, I'll rewrite the 4^4 as 16^2 on the left to get

1*16^2 + (2*4 + 1)*16 + (3*4 + 2)

and then evaluate the expressions in parentheses to get

1*16^2 + (9)*16 + (14)

We're almost there. Because 16^1=16 and 16^0=1, we get

1*16^2 + 9*16^1 + 14*16^0

This is now an expression involving powers of 16, each of which is


multiplied by a number less than 16. From the definition of base 16
number representation, and using the symbols 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, A, B, C, D, E, and F to represent all the required digit values
from 0 up to one less than the base, we can automatically read off
that the hexadecimal representation for this expression is

19E

Similar logic works to show why the original binary to octal technique
works. Follow the example above and do it to satisfy yourself why and
how that works. In that case, you are going from powers of 2 to powers
of 8.

I said this type of conversion technique works only when the larger
base is a power of the smaller. Strictly, that is true. But a closely
related process works when the two bases are BOTH powers of something
smaller. Converting from octal to hexadecimal is fairly easy if you
do it in two steps. First convert from octal to binary, and then
convert from binary to hexadecimal.

Note that octal to binary is just the opposite of binary to octal.


When going in that direction, you don't "group" but you "un-group."
Example: For octal 275, expand all the octal digits to get 10 111
101, to see that the binary equivalent is 10111101. Then re-group in
bunches of four as 1011 1101, from which you get BD in base 16.

You will have to work out a number of concrete examples yourself to


really absorb all of this. But now you have the tools and basic ideas
for doing that.

Go to it.

- Doctor Mike, The Math Forum


http://mathforum.org/dr.math/

You might also like