Convert Decimal Numbers to Hexadecimal Numbers

Reference & EducationEducation

  • Author Bruce Tucker
  • Published February 25, 2009
  • Word count 463

Most people will never have a need for this conversion but if you work in software development, IT, computer hardware or a slew of other areas surrounding the computer industry, you at some point will need to know how to do this.

As complex as it might sounds there is a very easy algorithm that you can use in order to figure out what the hexadecimal number equivalent is when given a decimal number.

As you might know decimal is base ten. It is the standard numbering system that is used everywhere in the world. Hexadecimal is base sixteen. From numbers one through nine they look identical, however once reach ten this is where it differs. Below is the decimal to hex conversion for numbers 1 through 15:

1 through 9 decimal = 1 through 9 Hex, (i.e. 1=1, 2=2, etc)

Decimal Number 10 = Hexadecimal Letter A

Decimal Number 11 = Hexadecimal Letter B

Decimal Number 12 = Hexadecimal Letter C

Decimal Number 13 = Hexadecimal Letter D

Decimal Number 14 = Hexadecimal Letter E

Decimal Number 15 = Hexadecimal Letter F

As you can see if you were converting a number from one through 15 it would be easy, but what if you had to convert say decimal number 3488 to its Hex equivalent. It’s easier than you think; here is how it is done.

In this article we represent division as the backslash ( / ). The backslash is commonly used in programming languages to represent division so I will use it here.

So our number to convert is 3488. The first step is to divide 3488 by 16. Remember Hex is base 16 so that is where we get the number from.

3488/16 = 218 with a remainder of 0 (zero)

Make a note of the number zero, that is part of our answer. The next step is to see if our answer is greater than or equal to 16. Well 218 is therefore we need to continue. Our next step is to divide 218 by 16.

218/16 = 13 with a remainder of 10

Again make a note of the number 10. That too is part of our answer. You can probably see where I am going with this. As long as the answer is greater than or equal to 16 you will keep dividing the answer by 16 until it is less than 16. Low and behold we are at that point in our example because 13 is less than 16. What do you do now? Well you have now have your answer and it looks like this:

13 10 0

But remember in Hex we only count numbers up through 9 and then use letters for 10 through 15. Therefore we have to convert the numbers greater than 9 in our answer to its letter equivalent. So for the answer we have:

13 = D

10 = A

0 = 0

So our final answer is DA0. You can confidently say that the Hex equivalent for decimal number 3488 is DA0.

You are now fully equipped to convert any decimal number to its Hex equivalent. Happy calculations!

About the Author: Mr. Tucker is a regular contributor on Bukisa, an online community for writers that pays them for their articles. You can also follow Bruce on Twitter.

Article source: https://articlebiz.com
This article has been viewed 622 times.

Rate article

Article comments

There are no posted comments.

Related articles