When we write a normal (base 10) number, like 5763, we mean the value:

$$5000 + 700 + 60 + 3$$

or, to put it in a more revealing form:

$$5 \cdot 10^3 + 7 \cdot 10^2 + 6 \cdot 10^1 + 3 \cdot 10^0$$

Notice, the "digits" of our number correspond to the coefficients on the powers of ten that are added together to obtain the value of our number.

In a similar manner, we can specify numbers in other "bases" (besides 10), using different digits that correspond to the coefficients on the powers (of the given base) that must be added together to obtain the value of our number.

For example, the "base 8" (or "**octal**") number (as indicated by the subscript)

$$5763_{(8)}$$

equals

$$5 \cdot 8^3 + 7 \cdot 8^2 + 6 \cdot 8^1 + 3 \cdot 8^0 = 3059$$

More generally, the "base b" number

$${d_n d_{n-1} d_{n-2} \ldots d_0} _{(b)}$$

equals

$$d_n \cdot b^{n} + d_{n-1} \cdot b^{n-1} + d_{n-2} \cdot b^{n-2} + \cdots + d_0 \cdot b^0$$

In order that every number have a base b representation, but no number has more than one such representation, we must only use the digits 0 through (b-1) in any given base b number.

This is consistent with base 10 numbers, where we use digits 0-9.

For smaller bases, we use a subset of these digits. For example, in base 5, we only use digits 0-4; in base 2 (which is also called **binary**), we only use the digits 0 and 1.

For larger bases, we need to have single digits for values past 9. **Hexadecimal** (base 16) numbers provide an example of how this can be done. In hexadecimal, we use digits 0-9 and A-F, where A=10, B=11, C=12, D=13, E=14, and F=15. In this way, we have digits corresponding to 0-15, which is what we need.

**Example**

$$5AF8 = 5 \cdot 16^3 + 10 \cdot 16^2 + 15 \cdot 16^1 + 8 \cdot 16^0 = 23288$$

(*Note: As shown above, the subscript indicating the base to be used is often left off in the case of hexadecimal and/or binary numbers. In these instances, the context of their use usually makes the base clear.*)

One (straight-forward, but inefficient) way to convert from base 10 to a different base is to:

- Determine the higest power of the base that goes into the number a non-zero number of times.
- Determine how many times this power can be subtracted from the number without the result being negative (i.e, divide the number by the power). Write this digit down.
- Redefine the number to be this smallest positive remainder upon division by the power in question
- Redefine the power to be the power divided by the base.
- Go back to step 2, unless the power is now less than one -- in which case, you are done.

For example, to convert 1073 to base 5, we recall that:

5^{0}= 1 5^{1}= 5 5^{2}= 25 5^{3}= 125 5^{4}= 625 5^{5}= 3125

Then we notice that 5^{4} = 625 is the highest power of 5 under 1073.

1073 =1* 625 + 448 448 =3* 125 + 73 73 =2* 25 + 23 23 =4* 5 + 3 3 =3* 1 + 0

The red digits, **13243**, reveal the base 5 representation of 1073.

This process, however, is inefficient in that one must both know and use the various powers of the desired base.

There is a simpler way!

Consider the remainders seen upon division of the following numbers by 5:

1073 = 214 * 5 +3214 = 42 * 5 +442 = 8 * 5 +28 = 1 * 5 +31 = 0 * 5 +1

Note: the base 5 representation comes from reading off the remainders (in red) from bottom to top!

In each step above, we are just dividing by 5 and looking at both the quotient and remainder -- no knowledge of higher powers of 5 is necessary!

Wonderfully, this technique works in any base. (*Can you explain why?*)

So, for example, if we wanted to find the binary (base 2) representation of 1000, we simply calculate the following:

1000 = 500 * 2 +0500 = 250 * 2 +0250 = 125 * 2 +0125 = 62 * 2 +162 = 31 * 2 +031 = 15 * 2 +115 = 7 * 2 +17 = 3 * 2 +13 = 1 * 2 +11 = 0 * 2 +1

So 1000 in binary is **1111101000**

Counting in other bases is not too different from counting in base 10. To see the similarities, let's count to 41 in base 10 and base 3 (as shown in the table below).

Pay particular attention to how "2" in base 3 plays the same role as "9" in base 10. It represents the last digit you can use before increasing the digit to the immediate left.

Base 10 | Base 3 | Base 10 | Base 3 | |
---|---|---|---|---|

0 | 0 | 21 | 210 | |

1 | 1 | 22 | 211 | |

2 | 2 | 23 | 212 | |

3 | 10 | 24 | 220 | |

4 | 11 | 25 | 221 | |

5 | 12 | 26 | 222 | |

6 | 20 | 27 | 1000 | |

7 | 21 | 28 | 1001 | |

8 | 22 | 29 | 1002 | |

9 | 100 | 30 | 1010 | |

10 | 101 | 31 | 1011 | |

11 | 102 | 32 | 1012 | |

12 | 110 | 33 | 1020 | |

13 | 111 | 34 | 1021 | |

14 | 112 | 35 | 1022 | |

15 | 120 | 36 | 1100 | |

16 | 121 | 37 | 1101 | |

17 | 122 | 38 | 1102 | |

18 | 200 | 39 | 1110 | |

19 | 201 | 40 | 1111 | |

20 | 202 | 41 | 1112 |

You can add in another base (without converting to base 10) as long as you remember that you "carry" when you have a sum that is greater than or equal to your base (instead of greater than or equal to 10), and that what you "carry" is the number of times you can pull out the base from your sum.

This is best illustrated by an example. Suppose you wish to add the hexadecimal numbers 4EF5A and 6ACF7:

1111 <---- These are the "carried" digits 4EF5A +6ACF7 ------ B9C51

Let's walk through the example. Notice that

A + 7 =11(hexadecimal calculations) 10 + 7 = 17 =1* 16 +1(decimal calculations)

So we write down a 1 in the "units" column and carry a 1. Then,

1 + 5 + F =15(hexadecimal calculations) 1 + 5 + 15 = 21 =1* 16 +5(decimal calculations)

So we write down a 5 in the "tens/sixteens" column and carry a 1. Then,

1 + F + C =1C(hexadecimal calculations) 1 + 15 + 12 = 28 =1* 16 +12(decimal calculations)

So we write down a C in the next column and carry a 1. Then,

1 + E + A =19(hexadecimal calculations) 1 + 14 + 10 = 25 =1* 16 +9(decimal calculations)

So we write down a 9 in the next column and carry a 1. Then,

1 + 4 + 6 =B(hexadecimal calculations) 1 + 4 + 6 =11(decimal calculations)

So we write down a B in the next column, and we are done.

Consider the following conversion from binary to hexadecimal:

100100010101111 (binary) = 0100 1000 1010 1111 4 8 10 15 = 4 8 A F Hence 10010001010111 (binary) = 48AF (hex)

Amazingly, one can always break a binary number into groups of 4 digits (starting at the right, and adding leading zeros if one runs out of digits), and then reinterpreting these groups of 4 as hexadecimal values, arrive at the hexadecimal representation for the original binary number. (*Can you figure out why?*)

Reversing the process is just as easy.

Suppose we wish to convert FC7 (hex) to binary form. Note that

F (hex) = 15 = 1111 (binary) C (hex) = 12 = 1100 (binary) 7 (hex) = 7 = 0111 (binary) Hence, FC7 (hex) = 111111000111 (binary)