Tag Archives: hexadecimal

Decimal, Binary, Octal, and Hexadecimal Number Systems Explained

When we talk about numbers, in most cases, we are referring to numbers composed of the digits 0–9. We don’t really put any thought into it, and just accept that this is how numbers are represented, because this is probably what we were taught when we were really young. However, this is just one possible numeral system that could be used to represent quantities. There are other systems that you could use, and in this post, I’m going to give brief introductions to the decimal, binary, octal, and hexadecimal number systems.

The decimal numeral system is the counting system most widely used around the world. You may also hear of it referred to as a base ten system. In fact, this is where the word “decimal” comes from; Latin “decem” means ten. When we say it is a base ten system, that means that each digit position has ten possibilities, or more specifically, can be any of the digits 0 – 9. So, if we count out 15 apples, we know that this breaks down to a 5 in the ones column and a 1 in the tens column, and so we automatically equate this as 1 times ten and 5 times one to make 15. This also shows the importance of each position in the number. In a base ten system, there is a column for ones, tens, hundreds, thousands, etc. All of this is probably very familiar already, so I’m not going to go into any further details of the decimal system.

Now, let’s look at the binary numeral system. While the decimal system is the most commonly used system, probably a very high percentage of people are at least aware of the binary system, though they probably don’t fully understand it. The binary system is a base two system, usually denoted as 0 and 1. In fact, the reason why binary is historically associated with computer programming is because this 0 and 1 can physically be represented in computer circuitry as being “open” and “closed” states – way more than I’m going to explain here, but interesting nonetheless. If we consider a base two system, we quickly see that counting is an entirely different experience. Unlike the base ten system with ones, tens, hundreds, since the base two system only uses two digits, instead it has digit positions for ones, twos, fours, eights, sixteens, etc. Each position is a factor of 2 greater than the position to its right, much like in base ten where each position is a factor of 10 greater than the position on its right.

Let’s count apples again to see binary counting in action:

  • 0 apples = 0 in binary
  • 1 apple = 1 in binary
  • 2 apples = 10 in binary
  • 3 apples = 11 in binary
  • 4 apples = 100 in binary
  • 5 apples = 101 in binary
  • 6 apples = 110 in binary
  • 7 apples = 111 in binary (= 1 one + 1 two + 1 four)
  • 8 apples = 1000 in binary

The important thing to realize is that physically, we have the same quantity of apples, regardless of the numeral system we are using to represent them. So to speak of 8 (base ten) apples or 1000 (base two) apples, we are really talking about the same thing.

We can apply these counting concepts to the other numeral systems as well. Let’s look at the octal numeral system first. As you can probably tell from its name, octal is a base eight system. So, each number position can have any of the digits 0–7, and the labelling of the positions goes up by a factor of 8 for each position. So, we have ones, eights, sixty-fours, five hundred twelves, etc. Let’s look at some apple quantities again, but in octal this time. You can figure out what 0–7 apples looks like in octal notation, but what about 8 or higher:

  • 7 apples = 7 in octal
  • 8 apples = 10 in octal
  • 9 apples = 11 in octal (= 1 one + 1 eight)
  • 10 apples = 12 in octal
  • 11 apples = 13 in octal (= 3 ones + 1 eight)
  • 20 apples = 24 in octal
  • 24 apples = 30 in octal
  • 30 apples = 36 in octal (= 6 ones + 3 eights)
  • 100 apples = 144 in octal (=4 ones + 4 eights + 1 sixty-four)
  • 750 apples = 1356 in octal (= 1 five hundred twelve + 3 sixty-fours + 5 eights + 6 ones)

Finally, let’s look at the hexadecimal number system. This system, also used frequently in computer programming, is a base sixteen system (as can be seen by its name: hexa- mean six and deci- means ten = 6+10 = 16). This counting system may take the most work to understand, but again, it follows the same rules. In this case, however, we run into a wrinkle. So far, we have looked at decimal, binary, and octal systems. All of these utilize at least some of the familiar digits 0–9. But how do we represent a number between 10–15 by only using a single digit? We only know of these quantities as two-digit numbers! Is there anything else we might use that is only a single character, without having to make up a brand new one? This is where hexadecimal is slightly different from the others. It uses 0–9 to represent those digits, though for 10–15 it uses the letters A-F. So, to write 10 in hexadecimal, it is simply A. Similarly, 11 is B, and so on. As a result, the number positions again are larger than the previous systems, so we have ones, sixteens, two hundred fifty-sixes, four thousand ninety-sixes, etc.

So counting apples again!

  • 13 apples = D apples in hex
  • 15 apples = F apples in hex
  • 16 apples = 10 apples in hex
  • 26 apples = 1A apples in hex
  • 100 apples = 64 apples in hex
  • 124 apples = 7C apples in hex
  • 50000 apples = C350 apples in hex

By including letter characters as digits, hexadecimal may be the most challenging of these number systems to wrap your head around. The bigger the numbers get, the more complicated they may seem. However, they all follow the same concepts and aren’t too difficult to figure out, once you get used to thinking in a number system other than base ten!