How to Convert Hex to Decimal and Decimal to Hexadecimal
By easyguyevo
About Decimal
- Before you convert decimal to hex and hex to decimal you must know what are decimal bits and hex bits.
- A bit in this tutorial represents a single number or letter.
- Decimal is also called base 10 and denary because it consists of ten numbers. Such as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
- Decimal is a number system.
- These are the numbers we use in every day counting. We mostly use this number system because we have ten fingers.
- The number ten (10) is made by using a combination of two of these numbers: one and zero (1 and 0). While two hundred and nine (209) is a combination of three numbers: two, zero and nine (2, 0 and 9).
- There is no limit as to how many times the numbers can be reused, that is why it is said that numbers are never ending!
About Hexadecimal (Hex)
- Hex is a representation of 4 binary bits
- Hexadecimal, which is also called base 16 or 'hex' for short, consist of sixteen numbers and letters.
- The numbers are the same as decimal numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
- But the big difference between hex and decimal is that hex also contains letters. These letters are: A, B, C, D, E, F.
- These letters come after their decimal friends if they are in ascending order. Therefore, the Hexadecimal series looks like this: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
- Hex can be considered as a shorter version of decimal. For example a large number in binary has a much smaller hex equivalent. I will demonstrate this later.
Hex to Decimal
Now to manually convert Hex to decimal and decimal to hex!
First you must know that the letters in hex all have decimal equivalents, as listed in the table below.
Now Lets convert Hex to decimal!
Example 1
To manually convert hex to decimal you must start by multiplying the decimal number by 16. Which will be raised to a power that increases by 1 (the power at which the hexadecimal is raised starts at zero 0), by the hexadecimal number decimal equivalent. We start from the right of the hexadecimal number and go to the left when applying the powers. Each time you multiply a number by 16 the power of 16 increases. I know this might seen confusing that is why i will provide examples! When converting C9 hexadecimal to decimal your working should look something like this:
Multiplication Result
9 * (16 ^ 0) 9
C = 12 * (16 ^ 1) 192
We then add the results.
192 + 9 = 20110
- First we changed all of our hex numbers to their decimal equivalents. C is equal to decimal 12 (refer to table above) and 9 is equal to decimal 9.
- We then multiply the numbers 12 and 9 starting from the last number in the question, by 16 and its power. Remember the powers start from zero.
- Our first multiplication has a power of 0 and the second multiplication has a power of 1. If there was a third it would have a power of 2 and 4 a power of 3 etc....
- The stars (^) in the bracket represent 'raised to the power of'. Therefore, the first terms in brackets read, 'sixteen to the power of 0'. What this means is that sixteen is multiplying by itself zero times. Anything raised to the power of zero is 1. Therefore, 9 is being multiplied by one.
- In the second bracket the terms read as, 'sixteen to the power of one'. A number raised to the power of one is equal to that number. Therefore 12 is being multiplied by 16. When we multiply these we get 192.
- We then added the results in the results column to get our decimal equivalent number. Which is 201
Example 2
Convert ABC to decimal
Remember we raise the number sixteen to zero for the rightmost bit of the question. As we move across the numbers and letter in the question the power 16 is raised to is 1 more than the previous bit. For example if we had a number with 22 bits the leftmost bit would be multiplied by sixteen to the power of 21.
Multiplication Result
C = 12 * (16 * 0) 12
B = 11 * (16 * 1) 176
A = 10 * (16 * 2) 2560
Answer = 2560 + 176 + 12 = 274816
Try these
Convert AF, ACD, AB2 and FF to base 10
Answers are 17510, 276510, 273810 and 25510 respectively
The subscript at the bottom shows the base
Now Lets Convert Decimal to Hex
Example 1
To convert from decimal to hex you must divide the decimal number by 16 repeatedly. Then write the last remainder you obtained in the hex equivalent column. While doing so, if the remainder is more than nine remember to change it to its hex letter equivalent. The answer is taken from the last remainder obtained. Refer to diagram below as an example
The answer is C9. As you can see it contains less bits than its decimal equivalent, 201.
- What we did was to divide our decimal number (base 10) by 16 to get our hex equivalent (base 16).
- Our decimal number is 201. We divided this by 16 to get a value of 12 with a remainder of 9. The hex equivalent for 9 is 9 so no change is made.
- We then divided our previous answer ,12, by 16. We got a value of zero and a remainder of 12. We then converted 12 to hex. Twelve's hex equivalent is C (refer to the first table). We then wrote our answer from the last remainder we received to the first in the order from left to right respectively.
Example 2
Convert 3000 to hexadecimal
Divisor Base 10 number Remainder in hex
16 3000
16 187 remainder 8 = 8
16 11 remainder 11 = B
16 0 remainder 11 = B
Answer equals to BB8. Remember we write the last remainder we received at the front of our answer
Try these
Convert 39554, 2857, 37 to base 16
Answers are 9A82, B28 and 25 respectively.
Conclusion
For some, this may seen difficult at first. But rest assured that with a little practice, converting from decimal to hex and hex to decimal can easily be mastered. You may check your answers using a calculator, type you decimal value in the 'dec' (may vary depending on calculator) setting and then select 'hex' (may also vary depending on calculator) and press equal. Just do the opposite for hex to decimal. Easy isn't it! Though, I strongly recommend that you learn how to convert these number systems manually before using the calculator. So that you won't have to rely on a calculator to convert them.
Was this hub easily understood and helpful?
See results without votingComments
NO prob, lol.
I've found most sites do not mention what you need to do with the remainder.
201 / 16 = 12.5625
To get the remainder of 9, like in the example, you need to take the remainder .5625 and multiply by 16.
201 / 16 = 12.5625
.5625 * 16 = 9
Converting is a two step process, yet for some reason no one ever mentions this, hope this helps someone!
No mention here that Hex is just a shorthand way of expressing a binary number, 4 bits at a time - that is why it is useful (Octal is 3 binary bits).
The article uses the term 'bit' in an odd and confusing way IMO



coder 20 months ago
Thanks for the directions and source code! :-)