Convert Decimals to Hex with this Easy Technique

The decimal number system is as old as humanity. Ever since our ancestors realized the number of fingers we had, they immediately latched on to it as the way we express numerical values to ourselves and others. It’s a great system that serves us well in most situations. Most people don’t need to know any other number system, but that does not mean it’s the perfect system for all problems. Sometimes, the numbers are too big to write reasonably well in decimal. It’s then when you need to know how to convert a decimal to hex.

The Decimal Number System

Before I can show you how to convert decimals to Hex, we have to review what decimals are. Hex, or hexadecimal, numbers use the same rules as decimals, and having a firm grasp of the decimal system will help us understand how to covert numbers between the two systems.

The decimal number system expresses values as sequences of symbols called digits. These digits are the familiar 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. We can write any number just by stringing together combinations of these digits. For instance, it we combine 5 and 7 we create 57.

Each digit in a decimal number represents the power of ten we have to multiply that digit to put it in that location. In fact, this is why the decimal number system is often called the base 10 number system. For instance, take the number 6954.023.

The Hexadecimal Number System

The decimal system served as well enough that we never needed another number system until fairly recently. It lets us count things with our fingers and toes giving us a way to keep track of values when we can’t write them down or otherwise can’t use them right away. In fact, we had to wait until the dawn of the computer age before the other number systems can of use to us.

It has been well known since ancient times that we can use any number as our numerical base. With the right modification, we can express any value as a power of any number we choose. However, for most of human history, these alternative number systems remained simply as interesting mathematical concepts. Computers changed this by offering several unique challenges that the decimal system could not handle. For instance, the binary number system was created because computer data was better represented as a series of on and off switches. Since there were only two states, we needed a number system of just two digits to visually represent the configuration of those switches.

Hex, or the hexadecimal number system, didn’t come into existence until data storage grew to the point where you could no longer write the values on a sheet of paper in either decimal or binary.

The hexadecimal number system, or base 16, expresses numerical values with sixteen different symbols. For simplicity, these symbols were cooped from the decimal system and the alphabet. Thus, a hex number is any sequence of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. The letters represent values from 10 to 15 respectively.

Like with the decimal system, the positions in a hex number represent the powers of 16 we have to multiply the digits to put them there. These positions include:

16^0 = 1

16^1 = 16

16^2 = 256

16^3 = 4096

16^4 = 65536

16^5 = 1048576

… And so on.

Converting Decimals to Hex

I was going to show you an example of an hex number, but the best way to do that is to simply show you how to covert decimal numbers to the hex system.

Converting a decimal number to hex is as easy as doing division. In fact, that is the procedure we use. Your first step is to find the highest possible power of 16 that will divide into your decimal. You then divide that power into your decimal and record the remainder. This remainder is your first hexadecimal digit. You might have to convert it to a hex digit, but you write it down as your answer. You then continue the process by using the quotient as your new dividend. You repeat the process until either the quotient becomes less than 16 or it vanishes. If the quotient is less than 16, it severs as our last hex digit. If the quotient vanishes, we fill in the rest og the hex digits with zeroes. If you did this properly, the sequence of hex digits will be the hexadecimal equivalent of your decimal number.

As an example, let’s convert the decimal 317547 to hex.

317547 ÷ 16 = 19846, with a remainder of 11. 11 is B in the hex system.

19846 ÷ 16 = 1240, with 6 left over. 6 in hex is still 6.

1240 ÷16 = 77, with a remainder of 6. 8 remains 8 in hex.

77 ÷16 = 4 with 13 left over. 13 becomes D in hexadecimal.

4 is less than 16 so it becomes our last hex digit.

Therefore, 317547 in hexadecimal is 4D86B.

While hexadecimal numbers can theoretically have fraction components, we rarely need to use them especially in computer storage and data processing where hex numbers represent collections of four binary bits. Therefore, you don’t have to worry about fractions when converting decimal numbers to the hexadecimal system. Just remember that hex numbers express numbers in powers of 16 rather than the powers of 10 we use in the decimal system. If you need to reverse the process, you just have to multiply each hex digit by its power of 16 and then add them together. Either way, you should be ready to convert any decimal to hex as well as into any other numerical base system in the universe.