I am a former maths teacher and owner of DoingMaths. I love writing about maths, its applications and fun mathematical facts.
What Are Hexadecimal Numbers?
The hexadecimal number system (often known simply as 'Hex') is a base-16 system of counting used commonly in computing. Whereas our normal decimal system of counting works in base 10, using the ten different digits 0-9, hexadecimal's base-16 means it uses sixteen digits; 0-9 and the letters A-F.
To understand this further, let's look at some examples.
Building Decimal and Hexadecimal Numbers
Both decimal and hexadecimal start in the same way; 0, 1, 2, 3, ..., 9. Once the decimal has reached 9, it has run out of digits and so we start another column on the left with a 1 and reset the original column to zero to get 10. We then keep on counting 11, 12, 13, etc. until we reach 19 and again reset our righthand column and add one to the left to get 20. Each time a column runs out of digits, we reset it to zero and add one to the column to the left e.g 99 to 100, 799 to 800 etc..
Hexadecimal however has extra digits A - F to continue through before extra columns are needed. We, therefore, start 0, 1, 2, ..., 8, 9, A, B, C, D, E, F where the letters A - F are equivalent to the decimal numbers 10 - 15. Once we reach F, we reset the column and start a new column to the left as in decimal. This next number is written 10. We then continue 10, 11, 12, ...,19, 1A, 1B, ..., 1F, 20 etc. Each time a column reaches F, we reset it and increase the column to its left.
Decimal's ten digits means that each column is worth 10 times the column to its right e.g. tens = 10 × units, hundreds = 10 × tens and so on.
In hexadecimal with its sixteen digits, however, each column is worth 16 times the previous. Therefore our first column is counting ones, the second column is counting 16s, the third column counts 162s (or 256s) and so on.
Converting Between Decimal and Hexadecimal
To convert from hexadecimal to decimal relies upon counting in powers of 16. For example, take the hexadecimal number 3B216 (in our notation, the subscript 16 tells us that this number, 3B2, is in hexadecimal form). As B is the 11th number in hexadecimal, this converts to 3×162+11×16+2×1 = 94610 (likewise the subscript 10 denotes a decimal number).
Similarly, the number EA1716 = 14×163 + 10×162 + 1×16 + 7×1 = 59 92710.
To convert from decimal to hexadecimal is a little trickier, but achievable with some division. First, work out what the highest power of 16 which will go into your number is. E.g. to convert 1782, we see that 1782>162 but <163 so we will divide by 162 to see how many times this fits and what remainder is left.
Read More From Owlcation
1782÷162 = 6.96... or 6 remainder 246, so our hexadecimal number starts with a 6. We then divide the remainder by 16, so 246÷16 = 15.375 or 15 remainder 6. This gives us F as our middle digit (as F16 = 1510) and 6 as our last digit, so 178210 = 6F616.
The First 18 Numbers in Decimal and Hexadecimal
Some Uses of the Hexadecimal Number System
We've looked at what the hexadecimal system is, but what is its purpose? As mentioned earlier, its main use is in computing. Computers run on a binary number system of 1s and 0s (read my article on binary numbers to find out more about how this works). This is great for a computer where 0s and 1s are matched to switches being off or on, but is difficult to write accurately as numbers which are quite small in decimal can have many digits in binary. e.g. 9810 = 1100010 in binary.
This is where hexadecimal comes in useful. As 16 = 24, one hexadecimal digit is equal to four binary digits e.g 916 = 01012 and F16 = 11112. We can therefore write binary numbers in the hexadecimal system by grouping our binary digits into groups of four bits which are known as 'nibbles'.
For example, the binary number 1101 0011 1010 1001 would become D3A9 which is much easier to read and write without fear of making an error.
Another advantage of hexadecimal is that it can express numbers in fewer digits than decimal, with each place representing one out of a possible sixteen rather than ten, hence uses less memory.
Using Hexadecimal for Colour Coding
One of the places you are most likely to have seen hexadecimal numbers while using a computer is in picking colours. When choosing colours on a computer you generally have the choice between several systems such as hexadecimal, RGB etc. The decimal RGB system gives the amounts of red, green and blue used in your colour out of a total of 255, so for example, pure red = (255, 0, 0), pure green = (0 255, 0) and pure blue = (0, 0, 255). Mixing these gives different colours such as (255, 255, 0) for yellow.
We can rewrite these colours by converting each number into hexadecimal and writing it as a six digit number preceded by #. For example, black = (0, 0, 0) = #000000 while red = (255, 0, 0) = #FF0000. (209, 136, 210) gives a shade of pink which can be written as #D188D2 as 20910 = D116 etc.
Bibliography and Further Reading
Below are some articles I read while writing this article, as well as some further reading.
- Electronics Tutorials - Hexadecimal Numbers
- Tutorials Point - Hexadecimal Number System
- Hexadecimal to Decimal Converter
- Teach Computer Science - Uses of Hexadecimal
This content is accurate and true to the best of the author’s knowledge and is not meant to substitute for formal and individualized advice from a qualified professional.
© 2021 David