General Base Conversions

### Converting to base10

In the previous block, we broke down our every day base10 system into columns, multiplied by a power of 10, then added together. With this method, we can build systems using any number for a base by just changing the powers. For example, let's examine a ternary (base3) numbering system. In a base3 system, each column represents a power of 3 (rather than 10, as in the decimal system). Also, the system has a radix of 3, meaning each column can take on only 3 different values: 0, 1, or 2.

ex. Write the base3 number $2123212_{3}$ in the decimal (base10) system:

(the right-hand-side of the equations are all in base10)
$2123=(2∗32)+(1∗31)+(2∗30)212_{3} = (2 * 3^2) + (1 * 3^1) + (2 * 3^0)$
$2123=(2∗9)+(1∗3)+(2∗1)212_{3} = (2 * 9) + (1 * 3) + (2 * 1)$
$2123=1810+310+210212_{3} = 18_{10} + 3_{10} + 2_{10}$
$2123=2310212_{3} = 23_{10}$


So the number $2123212_{3}$ , a number written using 3 as a base, is the equivalent of $231023_{10}$ in the base10 system.

Converting a non-decimal system to base10 is straight-forward:

1. In the base10 system (where we're used to doing our math), multiply each digit from the number in the alternate base (base3 in the above example) by the power of the base that's appropriate for that column.

2. Add the products together (still in base10). The result is the number that was originally written in an alternate base, now written in base10.

### Converting from base10

The exact same process for converting to base10 can be used to convert from base10 to another base. However, all of the math on the right-hand-side ( multiplication and addition) would need to be done in the alternate base system for it to work. So while it's possible... our brains are used to doing math in base10, so usually use subtraction instead. Here's an abstract step-by-step (we'll take a look at an example right after so it makes more sense):

1. Find the highest multiple * power of the base that will fit into the base10 number.

2. Write the alternate base number in the correct column, leaving blanks to the right of it (to fill in later steps).

3. Subtract the amount equivalent to the alternate base number from your current base10 number. This is now your remainder.

4. Jump back to step 1, using this remainder instead of your original number.

5. Repeat steps 1-4 until your remainder is 0.

ex. Write the decimal number $23510235_{10}$ in a base4 system.

Find the highest mulitple * power that will fit in $23510235_{10}$ . In base10, $44=2564^4 = 256$ , which is too high. So we'll start $43=644^3 = 64$ for our power, then 3 for our multiple- so we get $3∗43=1923 * 4^3 = 192$ . Remember, because it's a base4 system, the radix is 4, meaning that each column can only take on 4 possible values: 0, 1, 2, 3.

We'll place a 3 in the $434^3$ column, which is the 4th one to the left. The remaining places we'll leave blank

$23510=3___4235_{10} = 3\_\_\__{4}$


Now we can subtract 192 from our original 235 , since we're accounting for that 192 with the 3 in the 4th column of our new base4 number.

$23510−19210=4310235_{10} - 192_{10} = 43_{10}$


Using our remainder of $431043_{10}$ , jump back to step 1 and continue the process. The next column is $43=164^3 = 16$ , and the highest multiplier of $161016_{10}$ that will fit into $431043_{10}$ is 2: $16∗2=3216 * 2 = 32$ . So we'll put a 2 into the $424^2$ column.

$23510=32__4235_{10} = 32\_\__{4}$


Subtract our newest multiplier from our working remainder:

$4310−3210=111043_{10} - 32_{10} = 11_{10}$


So our new remainder is 11. Repeating the process again, our next column's power of 4 is 1 . The highest multiplier is 2 ( $2∗4=82 * 4 = 8$ ):

$23510=322_4235_{10} = 322\__{4}$


Calculate our new remainder:

$1110−810=31011_{10} - 8_{10} = 3_{10}$

With the new remainder of 3, and the final column being essentially a 1's column, we can fill in the final column with just 3 :
$23510=32234235_{10} = 3223_{4}$

So $23510235_{10}$ written in base4 is $322343223_{4}$