Number Conversions from Base 10

I have written a few posts (Post 1, Post 2, & Post 3) concerning various base number systems. In all of these posts, I covered how to convert from a non-decimal base into a decimal base. In other words, I covered how to get INTO base-10. This post is going to cover the inverse (decimal base into non-decimal base).

Modulus

We will need to start by reviewing the concept of modulus division. Let’s look at the standard division problem 5/2. We would typically say that the answer is 2.5 and this would be correct.

Now, modulus is simply the remainder of a division problem. Go back to when you were first introduced to division. In Texas, this is typically in 4th grade. Let’s take a look at that division problem of 5/2 again. When you were learning division, you would have said the answer was 2r1. The 1 is the modulus. When we’re writing the problem to just solve modulus, we would write it as 5%2.

Mechanics

Decimal to Octal

Let’s say that we have the decimal number (base 10) 4,814 and we want to convert it to an octal (base 8).

We will be building the number from right-to-left. The first thing we will do is solve 4,814/8. This equals 601r6. So, our first digit of the solution (starting on the right) is 6.

6

Now, we solve 601/8, which equals 75r1. So, our second digit of the solution (floating from right-to-left) is 1.

16

Now, we solve 75/8, which equals 9r3. So, our third digit of the solution (floating from right-to-left) is 3.

316

Now, we solve 9/8, which equals 1r1. So, out fourth digit of the solution (floating from right-to-left) is 1.

1316

Finally, we solve 1/8, which equals 0r1. So, our fifth and final digit of the solution (floating from right-to-left) is 1.

11316

So, the decimal number (base 10) 4,814 is equal to the octal (base 8) 11316.

As you can see, this is a bit of a process, but once you know the process, it is very simple. I now want to take a look at going to number systems with more digits than base 10, for example: base 16.

Decimal to Hexadecimal

Let’s say that we have the decimal number (base 10) 4,814 and we want to convert it to a HEX (base 16).

We start by solving 4,814/16, which gives us 300r14. Remember, that is number systems with more than 10 digits, we start using letters.

10 = A
11 = B
12 = C
13 = D
14 = E
15 = F

So, the first digit of our solution (building from right-to-left) is E.

E

Now, we solve 300/16, which gives us 18r12. So, the second digit of our solutions (building from right-to-left) is C.

CE

Now, we solve 18/16, which gives us 1r2. So, the third digit of our solution (building from right-to-left) is 2.

2CE

Finally, we solve 1/16, which gives us 0r1. So, the fourth digit of our solution (building from right-to-left) is 1.

12CE

So, the decimal number (base 10) 4,814 is equal to the hexadecimal (base 16) 12CE.