Hexadecimal is a base sixteen number system. This means that there are sixteen symbols which can represent a single digit, adding A, B, C, D, E and F to the digits of the decimal system. It is more difficult to convert from decimal to hexadecimal than the other way around. Take your time to learn the correct method, as it's easier to avoid mistakes once you understand how the conversion works.
Convert small numbers
Method 1 of 2: Use the intuitive method
Step 1. Use this method at the start
Of the two methods presented in this guide, this one is the simpler. If you are already comfortable with the different basics, try the method outlined below.
If this is your first time experimenting with the hex system, you should start by learning the basics
Step 2. Write the powers of 16
Each digit in a hexadecimal number represents a different power of 16, as each decimal digit represents a power of 10. The list of powers of 16 will be useful to you during the conversion process.
- 165 = 1 048 576
- 164 = 65 536
- 163 = 4 096
- 162 = 256
- 161 = 16
- If the decimal number you want to convert is greater than 1,048,576, calculate powers greater than 16 and add them to the list.
Step 3. Find the greatest power of 16
Write down the number you are about to convert. Refer to the list above. Find the power of 16 that is greater than the decimal number.
For example, if you want to convert "495" to hexadecimal, you must choose "256" from the list
Step 4. Divide the decimal number by the power of 16
Stop at the whole number and ignore the rest of the result after the comma.
- For example: 495 ÷ 256 = 1, 93…, but only the “1” interests us here.
- Your answer is the first digit of the hexadecimal number. In this case, since we did a division by 256, the 1 is the one in the 256th place.
Step 5. Find the rest
This lets you know what is to the left of the number you converted. Here's how to calculate it, as you would in a long division:
- Multiply the last answer by the divisor. In our example: 1 x 256 = 256. (In other words, the 1 of the hexadecimal number represents 256 in a base 10).
- Subtract the answer from the dividend. 495 - 256 = 239.
Step 6. Divide the remainder by the next highest power of 16
Refer to the list of powers of 16. Move down to the next smaller power. Divide the remainder by this value to find the next digit of your hexadecimal number. (If the remainder is less than this number, the next digit is zero).
- 239 ÷ 16 =
Step 14.. Once again, you ignore anything after the comma.
- This is the second digit of your hexadecimal number, in the sixteenth place. All digits 0 to 15 can be represented by a single hexadecimal digit. We will convert the correct notation at the end of this method.
Step 7. Find the rest again
As you did before, multiply the answer by the divisor, then subtract the answer from the dividend. You will then need to convert the rest.
- 14 x 16 = 224.
- 239 - 224 = 15, so the remainder is
Step 8. Repeat until the remainder is less than 16
Once you get a remainder between 0 and 15, it is possible to convert it directly to a single hexadecimal digit. Write down this last number.
The last “digit” of our hexadecimal number is 15, in the “first place”
Step 9. Write the answer in the correct notation
You now know all the digits of the hexadecimal number. So far, we've written them all in base 10. To write each digit correctly with hexadecimal notation, convert them using the following guide.
- The numbers between 0 and 9 remain the same.,
- 10 = A, 11 = B, 12 = C, 13 = D, 14 = E and 15 = F.
- In our example, we end up with the numbers (1) (14) (15). With the correct notation this becomes the hexadecimal number 1EF.
Step 10. Check your work
It's easy to verify your answer once you understand how hex numbers work. Convert each of the digits to their decimal form, then multiply by the power of 16 for the position they occupy. Here is what you need to do for our example.
- 1EF → (1) (14) (15)
- From right to left, 15 is in 160, that is to say the first. 15 x 1 = 15.
- The next digit on the left is in 161 = 16th position. 14 x 16 = 224.
- The next digit is in 162 = 256th position. 1 x 256 = 256.
- Adding them all together, 256 + 224 + 15 = 495, the starting number.
Method 2 of 2: Use the quick method (with leftovers)
Step 1. Divide the number by 16
Treat the division as an integer division. In other words, get the whole number and leave out the numbers after the decimal point.
- In our example, let's be ambitious and try to convert the decimal number 317 547. Calculate 317 547 ÷ 16 = 19 846 and ignore the digits after the decimal point.
Step 2. Write the remainder in hexadecimal notation
Now that you've done the division, the rest is the part that doesn't fit in the sixteenth place or higher. So the rest must be in first place, the latest digit of the hexadecimal number.
- To find the remainder, multiply your answer by the divisor, then subtract the result from the dividend. In our example: 317,547 - (19,846 x 16) = 11.
- Convert the number to hexadecimal using the list of small numbers at the beginning of this article. In this example, 11 becomes B.
Step 3. Repeat the process with the quotient
You converted the rest to hexadecimal. Now continue to convert the quotient and divide it by 16. The remainder is the second digit of the hexadecimal number. It works with the same logic as before: the starting number has been divided by (16 x 16 =) 256, so the remainder is the last number that cannot stay in the 256th position. We already know the number in the first position, the rest must be in the sixteenth position.
- In our example: 19 846/16 = 1240.
- The remainder is 19,846 - (1240 x 16) =
Step 6.. It is the second digit of the hexadecimal number.
Step 4. Repeat until the quotient is less than 16
Remember to convert the remainder between 10 and 15 to hexadecimal notation. Write each of the leftovers as you go. The final quotient (less than 16) is the first digit of the number. Here is how our example continues.
- Take the last quotient and divide it again by 16. 1240/16 = 77 remainder
- 77/16 = 4 remainder 13 = D.
- 4 <16 so
Step 4. is the first digit.
Step 5. Complete the number
As was mentioned earlier, you find each digit of the hexadecimal number from right to left. Check your work to make sure you wrote them in the correct order.
- Your final answer is 4D86B.
- To verify your answer, convert each digit to its decimal equivalent, multiply it by the powers of 16, and add the results. (4 x 164) + (13 x 163) + (8 x 162) + (6 x 16) + (11 x 1) = 317547, the starting number.
- To avoid confusion when using the different numbering systems, you can write down the base used with a subscribed number. For example, 51210 means 512 in base 10, an ordinary decimal number. 51216 means 512 base 16, which is equivalent to the decimal number 129810.