Mr Goff logo

Computer Science

About hexadecimal

Hexadecimal is a base 16 counting system meaning it can represent the numbers from 0 to 15 in each column. For numbers bigger than 9 the letters a to f are used as seen in the table below.

Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

This page deals with 2 digit hex numbers. With a hex number 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.

Decimal to hexadecimal

Use the area below to generate a random number to practice converting numbers from decimal to hexadecimal.

Example

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.



Computer Science Home