In everyday life, there are ten symbols that we normally use to quantify- or count- objects. These are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. This is referred to as the decimal system; the prefix “deci-” means ten, and we have ten symbols in this system to represent numbers. You may have also heard of the binary number system, where we only use two numbers- 0 and 1- to count with; the prefix “bi-” means two, and there are two symbols in this system to represent numbers. But did you know that there are number systems that go beyond the decimal system and use more than ten symbols? One such number system that is widely used in the world of technology is the hexadecimal system. The hexadecimal system, as the prefix hexadeci- implies, uses sixteen symbols to count with.
The Symbols of the Hexadecimal Number System
The first ten symbols of the hexadecimal are the same as the decimal system, 0 through 9; however, once we hit 9, we technically “run out” of symbols to use. As a result, we switch to using single letters to represent the numbers above 9, as shown in the table below.
| Decimal | Hexadecimal |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
| 7 | 7 |
| 8 | 8 |
| 9 | 9 |
| 10 | A |
| 11 | B |
| 12 | C |
| 13 | D |
| 14 | E |
| 15 | F |
So, instead of using two symbols, 1 and 0, to represent the number ten, we use a singular letter A. Instead of 1 and 1 for eleven, we use the letter B. Twelve is the letter C instead of 1 and 2, and so on. By switching these two digit numbers to single characters, we are able to count in the hexadecimal system.
Converting Between Decimal and Hexadecimal
Like converting between decimal and binary numbers, converting between decimal and hexadecimal takes a little bit of math and practice. While each position in the decimal system represents a power of ten, each position of the hexadecimal system represents a power of sixteen. For example, the number 123 in the decimal system means we have one 102, or one 100, two 101s, or two 10s, and three 100s, or three 1s (since anything raised to the 0th power is 1). However, if we were in the hexadecimal system, this would look a little bit different. Let’s convert 123 in hexadecimal to decimal.
We would have one 162 (162 = 16 * 16 = 256), two 161s (161 = 16), and three 160s (160 = 1). In other words, we have one 256, two 16s, and three 1s; adding those together, we get the number 291 in the decimal system. It can be difficult at first to think in terms of powers of 16 if you are used to only the decimal system, but once you get the basics down, it becomes a lot easier.
This conversion from hexadecimal to decimal works the same if we have a letter in our hexadecimal number. For example, say we have the hexadecimal number ABBA. We know that A = 10 and B = 11 in the hexadecimal system, so when we break down this number, we would get:
Ten 163s (163 = 16*16*16 = 4096), eleven 162s, eleven 161s, and ten 160s.
In other words, we have ten 4096s, eleven 256s, eleven 16s, and ten 1s to add together to get our decimal number: 40960 + 2816 + 176 + 10 = 43962.
If you want to practice converting from hexadecimal to decimal, try the following (the answers can be found at the end of the article to check your work):
1. 18C
2. 7E9
3. B4
Converting from decimal to hexadecimal, however, might appear tricky at first glance. Say we have the number 930, and we want to convert it over to hexadecimal. What we need to do to convert it is continually divide the number by 16 and mark down what remainder we receive. Then we simply write out the remainders in reverse order.
For example, if we divide 930 by 16, we would normally get 58.125. To find the remainder, we can multiply 16 by the numbers after the decimal point; for example, 16 * .125 = 2.
930 / 16 = 58.125; 16 * .125 gives us a remainder of 2. We then divide 58 by 16.
58 / 16 = 3.625; 16 * .625 gives us a remainder of 10. We then divide 3 by 16.
3 / 16 = 0.1875; 16 * 0.1875 gives us a remainder of 3. Since we have reached 0, we can stop dividing.
Our remainders are 2, 10, and 3; in reverse, 3, 10, and 2. However, we know that 10 in hexadecimal is represented by the letter A, so our remainders become 3, A, and 2. Putting those together, we get the number 3A2 in hexadecimal, which is equal to 930 in decimal.
If you want to practice converting from decimal to hexadecimal, try the following (the answers can be found at the end of the article to check your work):
4. 1102
5. 867
6. 25
Khan Academy has a great video that explains the basics of the hexadecimal system as well as how to convert between the two systems:
What is Hexadecimal Used For?
Hexadecimal is widely used to digitally represent color. Specifically, hexadecimal numbers are used to determine how much red, green, and blue make up a particular color on a scale from 0 to 255. These particular numbers are usually written with six total symbols and are often referred to as hex codes or hex values. The first two numbers indicate how much red to include, the second two indicate how much green to include, and the last two indicate how much blue to include.
For example:
FF0000 is entirely red, with no green or blue.
00FF00 is entirely green, with no red or blue.
0000FF is entirely blue, with no red or green.
000000 is entirely black, with no red, green, or blue.
FFFFFF is entirely white, with red, green, and blue all being at maximum.
Encoding colors in this format makes it possible to store each color as a particular, concrete value on a set scale instead of needing to describe it more abstractly (for example, we can simply tell a computer we want color 4FE0E3 instead of trying to explain that it is a mixture of blue and green with slightly more blue than green but also with some red included to make it slightly darker). As a result, you can always guarantee that two colors are exactly same as long as they share the same hex value.
Practice Question Answers
1. 18C in hexadecimal is 396 in decimal.
One 162 + eight 161s + twelve 160s = (1 * 256) + (8 * 16) + (12 * 1) = 256 + 128 + 12 = 396.
2. 7E9 in hexadecimal is 2025 in decimal.
Seven 162s + fourteen 161s + nine 160s = (7 * 256) + (14 * 16) + (9 * 1) = 1792 + 224 + 9 = 2025.
3. B4 in hexadecimal is 180 in decimal.
Eleven 161s + four 160s = (11 * 16) + (4 * 1) = 176 + 4 = 180.
4. 1102 in decimal is 44E in hexadecimal.
1102/16 = 68.875; 16 * .875 = 14
68/16 = 4.25; 16 * .25 = 4
4/16 = 0.25; 16 * .25 = 4
Remainders: 14, 4, 4
14 = E in hexadecimal
Remainders: E, 4, 4
Reversed: 4, 4, E
44E
5. 867 in decimal is 363 in hexadecimal.
867/16 = 54.1875; 16 * .1875 = 3
54/16 = 3.375; 16 * .375 = 6
3/16 = 0.1875; 16 * .1875 = 3
Remainders: 3, 6, 3
Reversed: 3, 6, 3
363
6. 25 in decimal is 19 in hexadecimal.
25/16 = 1.5625; 16 * .5625 = 9
1 / 16 = 0.0625; 16 * 0.0625 = 1
Remainders: 9, 1
Reversed: 1, 9
19
Further Reading
Khan Academy’s Article on Hexadecimal Numbers: https://www.khanacademy.org/computing/computers-and-internet/xcae6f4a7ff015e7d:digital-information/xcae6f4a7ff015e7d:hexadecimal-numbers/a/hexadecimal-numbers




Leave a comment