0

## Convert Decimal to Any Base 2 - 9

Published on Sunday, October 05, 2014 in , , , , About 2 years ago, I posted about Russian/Egyptian multiplication, and included a technique for mentally converting decimal (base 10) into binary (base 2).

Recently, Presh Talwalkar covered this same technique on his Mind Your Decisions blog. I've only just realized that with a little modification, this technique can be used to quickly and mentally convert decimal to any base 2 through 9!

We'll use the Mind Your Decisions binary conversion video as a starting point. It's less than 3 minutes long, so it's a quick study:

In both my original Power of 2 post and the above video, the idea of ignoring the remainder is emphasized. Funnily enough, changing the technique to focus on the remainder makes this basic idea much more usable. If you remember division problems with answers like, “22 ÷ 6 = 3 remainder 4”, that's the type of division we'll be using in this post.

The first step is simply to take the given number and divide it by whatever base you're using, so that you have a quotient and a remainder. For a starting example, we'll convert the decimal number 84 into base 5. 84 ÷ 5 = 16 (the quotient), remainder 4.

The second step is to write down the remainder. In our example, we'd simply write down the 4.

Step 3 is to divide the quotient by the base again. This time, we'd work out 16 ÷ 5 = 3 remainder 1.

Step 4 is to write down this remainder to the immediate left of the previous remainder. Writing down the 1 to the immediate left of the 4 gives us 14.

Repeat steps 3 and 4 until you get a quotient of 0, at which point, you've got your answer! Finishing up our example, we'd use our current quotient of 3, divide that by 5, getting an answer of 0 remainder 3, write the 3 down to the left of the previous remainders, giving us 314. Since our quotient is 0, we also know we're done! Checking with Wolfram|Alpha, we see that 84 in base 5 is indeed 314!

TIP #1: Once your quotient is a number less than your base, you can simply write that to the left of the remainders and know you're done. In the above example, once we got down to 3, and we realize this is less than 5, we know this is the final step. Because of this, we can simply write the 3 down and stop.

In short, as long as you're given a decimal number and a base by which you're comfortable dividing that number, you can convert that number to that base in your head with little trouble. Not surprisingly, knowing division shortcuts and divisibility rules can be of great help here.

What about 147 (in base 10) to base 4? As long as you realize that the closest multiple of 4 is 144, and that you can handle 144 ÷ 4 in your head, the rest of the conversion shouldn't be a problem. 147 ÷ 4 = 36, remainder 3. Write down the 3, and then work with 36. 36 ÷ 4 = 9, remainder 0, so write the 0 to the left of the 3 (03), and work with 9. 9 ÷ 4 = 2, remainder 1. Write down the 1 to the left of the previous remainders (103). Tip #1 above tells us that, since 2 is less than 4, we can just write down that 2 to the left of the other numbers (2103) and know we're done. Sure enough, 147 in base 4 is 2103!

TIP #2: If the given number is less than the square of the base to which you're converting, you can do everything in a single step. All you have to do is work out the quotient and the remainder, write the quotient to the left of the reminder, and you're done! For example, what is 59 in base 8? 59 ÷ 8 = 7 remainder 3. Write down the 3 as before. Thanks to tip #1, we know that we can write the quotient down to the left, since 7 is less than 8, so we just write the 7 down next to it!

For base 8, this will work for any number less than 8 × 8, or 64. Similarly, for base 5, this will work for any number less than 25 (5 × 5), and so on. 44 in base 7? 44 ÷ 7 = 6 remainder 2, so we can quickly give the answer as 62!

Being able to convert to base 2 and base 8 in your head can be a great asset when working with computers. Practice this skill and have fun with it. You'll not only have a useful skill, but something with which to amaze and amuse others, as well!