Hexadecimal

<< Previous: Units Next: Hexadecimal and binary >>

About hexadecimal

Hexadecimal is a base 16 counting system. This means there are 16 possible digits that can go in each column. The digits 0 to 9 remain the same with the next 6 digits being A, B, C, D, E, AND F. In hexadecimal we can record up to 15 1s in the first column so the next column is the number of 16s we have. You only have to be able to work with two digit hex numbers which covers 0 to 255.

Converting hexadecimal to decimal

With 2 digit hex numbers, the digit in the column on the right is the number of 1s in a number with the lowest value being 0 and the highest being F representing 15. The second column therefore represents the numer of 16s in the number.

Column_heading 16s 1s
Value C 4

The value C4 shown above is equal to C x 16 + 4 = 12 x 16 + 4 = 192 + 4 = 196.

Hexadecimal to decimal practice

For our example let's convert the hexadecimal number A7 to it's decimal equivalent.

The formula for this is decimal = first hex digit x 16 + second hex digit. To use the formula simply slot in the hex digits and if they are letters convert them to their decimal equivalent e.g. A = 10, B= 11 etc. Then work through the maths to the solution.

So in our example decimal = A x 16 + 7 = 10 x 16 + 7 = 160 + 7 = 167.

Therefore our A7 in hexadecimal is equivalent to 167 in decimal.

Click the button to get a number to convert

Enter the decimal equivalent above.



Decimal to hexadecimal

For our example let's convert the decimal number 94 to it's hexadecimal equivalent.

The first step is to perform a floor division of the number and 16. Floor division is where we get the answer to one number divide another ignoring any remainder. This will be the first hex digit so in our case 94//16 = 5.

Next we find the remainder of the same division. In Computer Science finding the remainder of a division is known as modulus. In our case 94 % 16 = 14 i.e. 94/16 = 5r14. Because our number is bigger than 9 we have to swap our decimal representation for its hex equivalent - E.

Therefore our final hex number is 5E

Column_heading 16s 1s
Value 5 E

Double checking the maths by going back the other way we can see that 5 x 16 + 14 = 80 + 14 = 94

Decimal to hexadecimal practice

Click the button to get a number to convert

16s 1s

Enter text characters in lower or upper case.



<< Previous: Units Next: Hexadecimal and binary >>

© All materials created by and copyright S.Goff