# Hexadecimal Math – CompTIA Network+ N10-006 – 5.2

Computers and networks often represent information in hexadecimal form. In this video, you’ll learn how to convert decimal to hexadecimal and back again.

<<** Previous:** Modulation Techniques**Next:** Octal Math >>

A hexadecimal numbering system is one that is base 16. Although this seems a little unusual for us human beings that are so accustomed to working with base 10, for a computer that’s dealing with one byte is equal to 8 bits, having a base 16 numbering system is something very native to the computer. Fortunately, it’s very easy to convert back and forth from hexadecimal to decimal and back again. And so we’ll perform a number of calculations during this video.

Let’s create a conversion chart that we’re going to use to perform these hexadecimal calculations. We’ll have four different places. And we’ll start on the far right and put a 1. And then we’ll multiply 1 by 16, that’s obviously 16. We’ll multiply 16 by 16 and get 256.

And 256 times 16 is 4,096. If we wanted to view this a different way, you could think of this as 16 to the 0 power, to the first power, to the second power, to the third power, and so on. In hexadecimal, we represent the numbers 0 through 15 a little bit differently than we do in the decimal form. We can write this down by going zero through 9, but as soon as you get to 10, instead of using that decimal form of 10, we’re going to use the letters a, b, c, d, e, and f all the way up to number 15.

So there’s our 16 spaces in decimal, 0 through 15, but in hexadecimal, it is zero through f. Let’s use this conversion chart to now perform a couple of conversions between decimal and hexadecimal and back again. Our first question is what is the decimal value for 0x8. That 0x specifies that this is a hexadecimal value. So 0x8 is 8 in hex.

And if we look at our conversion chart, 8 in hex happens to equal 8 in decimal as well. Let’s do another one. What’s the decimal value for 0xc? So if we look at our conversion chart, c is equal to 12 in decimal. And let’s do the reverse.

If we want to know the hex value for 14 decimal, we simply use our conversion chart to go down to 14, and we see that the hexadecimal value for 14 is 0xe. Now that we have our hexadecimal conversion chart and we understand the differences between the decimal numbers and the hexadecimal values, we can start performing some hexadecimal math. So our first question is what is the decimal value of 0x27? Well, we’re going to put in our conversion chart right at the top with the 4,096, 256, 16, and 1.

And in this case, we have two places, a 2 and a 7 since we’re converting hex 27. So we’ll just bring down the 2 and the 7 in the farthest right sections. What we want to do now is multiply these different values. We want to multiply 16 times 2. We’ll get 32.

And we want to multiply 1 times 7. And of course, we’ll get seven. Now we simply add up all of these numbers at the bottom. 0 plus 0 plus 32 plus 7 is 39. So the decimal value of a hexadecimal 27 is 39.

Let’s do another one. We’re just putting these numbers right into our conversion chart and multiplying and adding all of those up. So we’ll look at a hexadecimal 3c and we’ll convert that to decimal. So we’ll bring down our 3 and our c, and then we’ll perform our multiplication. 16 times 3 is going to be 48.

1 times 12 is going to be 12. We add those up and the decimal value of hex 3c is 60. Now let’s perform the conversion the other direction where we have a decimal number and we want to determine the hexadecimal value. So in this question, we want to know the hexadecimal value of 122 decimal. So we’ll put our conversion chart down.

We want to put the 122 in our conversion chart, but we want to put it as far as possible to the left, and we want the 122 to be greater than the number that’s in the conversion chart. So if we go all the way to the left, 122 is not greater than 4,096. 122 is not greater than 256, but 122 is greater than 16. So we’ll place the 122 in this column. Now we want to perform the division.

So 122 divided by 16 is 7, and that leaves us with a 10 remainder. So we’ll put the 10 in the next column to the right. 10 divided by 1 is obviously 10. And so there is the division for the 122 separated into the different columns. Now we want to convert that into its hexadecimal equivalent.

So 7 in hex is also 7 and 10 decimal in hex is a, so there is our conversion. The hexadecimal value of 122 decimal is 7a. Let’s do another one. Let’s take the value 350 decimal and determine what its hexadecimal equivalent is. Again, we want to put the 350 in the column where the 350 is greater than the number that is in our conversion chart.

So if we start at the far left, 350 is not greater than 4,096, but 350 is greater than 256. Now we’ll begin our division. 350 divided by 256, goes one time with a remainder of 94. 94 divided by 16 is 5 with a remainder 14. And 14 divided by 1 is 14.

Now if we do our conversion, one decimal is 1 hex. 5 decimal is also 5 in hexadecimal. And 14 decimal is e in hexadecimal. And that means that the hexadecimal value of 350 decimal is 0x15e. Now that you know how to perform this math to convert decimal to hex and hex back to decimal, you can take any number, put it into this chart, and begin calculating these for yourself.

**Category**: CompTIA Network+ N10-006