Hexadecimal. The stuff inside your computer. But what is hexadecimal really? What do the strange and unfamiliar looking hexadecimal numbers stand for? How did hexadecimal come about? Learn more about hexadecimal today.
What Is hexadecimal?
The hexadecimal numbering system uses sixteen symbols (0 to 9 and A to F) to form and represent any number. The hexadecimal system is used inside computer and calculators. Hexadecimal is often abbreviated to hex and hex comes from the word hexagon, i.e. six. You can immediately see the connection with hexa..decimal as decimal stands for ten (10) and hexa stands for 6 (A-F, 6 characters).
Computers will often use hexadecimal inside their internal calculation systems. There is a direct connection between binary and octal numbers and hexadecimal numbers. To learn more about the 16-base (16 base items, 16 base numbers) hexadecimal numbering system, we need to step back a little and first explore binary and octal. If you haven’t heard these terms before, don’t worry, it is not nearly as complex as it sounds.
What Is Binary?
Binary numbers, particularly the binary numbering system, is one of the most, if not the most simple numbering systems on the planet. There are only two possible numbers in binary (hence the term binary, i.e. composed of two things), and that is zero (0) and one (1). Whilst we use the zero and one to represent our two possible numbers in this system, please realize this is just a choice – just like I would use the Latin-script letters A-Z to represent words in English or Chinese characters to represent words in Chinese.
We could have thus created a binary code that did not use zero and one but A and B, or $ and %, it matters little. However, there is a bit of an interesting caveat here, which does, in fact, make it easier to use zero and one for binary; computers only understand one thing: power or no power. Think about this like one or zero: one means +5V (5 Volts), and zero means 0V (0 Volts). It’s a little oversimplified, perhaps, but it is a good analogy of what happens inside a computer. Thus, we have binary.
So how does one count in binary, the 2-Base numerical system? We all know how to count in decimal (the 10-Base numerical system we use every day for all our expressions of quantity and more), 0… 1… 2… 3…, but how do we do this when we cannot even get beyond 1 towards 2? Well, what happens when we get to 9 and need to find the next number? We add a one on the front (the first digit in 10) and reset our secondary position to 0. We continue doing so to count further to 99, and then we do the same, though this time we reset two positions.
We can use the same method in our 2-Base Binary calculation, and this is exactly what we do and how we count. Here we go: 0… 1… 10… 11… 100… 101… 110… 111… 1000…. Not hard, right? If you did not know how to count in binary yet, congratulations, you now know how to! These days this skill is taught in approximately the first grade of high school. Let’s move on to octal.
What Is Octal?
So far we discovered that decimal could also be labeled as 10-Base because it has 10 different symbols to express numbers in (being 0 to 9), and that 2-Base only had zero and one. We now introduce octal, yet another computer oriented numerical system which has 8 possible symbols. You guessed it, zero (0) to seven (7). You can start seeing why such number systems exists: welcome to the power of two’s: 2 (binary) > 4 (half a byte) > 8 (octal, a byte) > 16 (hexadecimal).
So what is a byte? A byte is eight bits together (usually visually shown as 2 sets of 4 bits, though for a computer, it is simply 8 bits in a row), forming a single byte. For example, 0110 1100 is a valid byte, consisting of 8 bits. This number can be translated to octal (154), to hexadecimal (6C), and to decimal (108). Note here how the values for a higher number of base symbols numerical system is lower, like 6C in hexadecimal versus the long number in decimal, and the medium length number 154 in octal.
A byte is often used to store simple alphanumeric characters. For example, the letter ‘A’ is written in binary as 0100 0001. Note that the maximum value in a byte (i.e. 1111 1111) is 255 and there are thus only 256 possible combinations (+1 as 0 is a possible setting too) which can be made with a single byte. Thus, our limited A-Z range, even including numerals 0-9 and lowercase a-z still all together easily fits into a single byte, and we can even represent some other symbols like ‘@’ and ‘!’.
However, when it comes to for example, Chinese with its many different symbols, we may need two or more bytes to store our individual characters, i.e. multi-byte characters.
Returning to octal, how does one count in octal? You guessed it: the same method, simply cycling each round alike to decimal and binary as we saw. Let’s count together: 0… 1… 2… 3… 4… 5… 6… 7… 10… 11… – Looks a bit odd, no? It is because our minds are so attuned to think about 10, well, as “10”. But 10 in octal is 8 in decimal. Confusing? To us mere humans, yes, 8-Base octal can be confusing. To a computer, not really.
Counting in Hexadecimal?
This brings us back then to counting in our 16-base numerical system: hexadecimal. We now know the steps to follow and can count (with a small skip from zero to nine): 0… skip to… 9… A… B… C… D… E… F… 10… 11…. We now understand that 10 in hexadecimal, alike to octal, has a different meaning than what we read into it, as we are counting in hexadecimal which is 16-Base and not in decimal which is 10-Base. 10 In hexadecimal is really 16 in decimal!
It is noteworthy that hexadecimal, exactly because it is 16 base, allows us to store an entire byte in two characters! We cannot do this with decimal, as the binary value 1111 1111 (i.e. 1111111 to a computer) is 255 in decimal. However, in hexadecimal, it can be represented by FF, which is 255 in decimal. Note also that half a byte, 4 bits, can be stored in a single hexadecimal character.
We hope you have enjoyed this introduction to hexadecimal, our 16-character or 16-Base numerical system, and by extension to binary, the 2-Base numerical system and octal, the 8-Base numerical system. We also learned how the counting we do every day in decimal, our very familiar 10-Base numerical system uses the numbers 0 to 9.
We also saw that the symbols we use to represent binary, octal, hexadecimal and even decimal values are just that: symbols humankind chose to represent these different numerical systems. We could easily have chosen different representations for other numerical systems, but re-using the same numericals feels familiar and makes some sense, especially in the case of binary with power and no power represented by zero and one.
Enjoy teaching someone to count in binary, octal or hexadecimal today!
And, if you enjoyed this article, have a look at Bits, Bytes and Binary.