Decimal, Binary, and Hexadecimal Basics: Positional Number Systems
Everyone knows that calculators can manipulate binary-to-decimal conversions and the like. However, it will increase your understanding of computing immensely (and make other tasks easier) if you just take the time to look at positional number systems and how they work. No memorization necessary! No adding a long string of numbers to get a single answer, either.
If numeric conversion is not the end goal, then why are we doing this? It is so that you can begin to recognize whether or not symbols fall in or out of numeric ranges. For instance, you probably know that 300 lies between 298 and 324. What about ABF4 and the range of AB10 to ABE7? (It is outside.)
In any positional number system, the ultimate numeric value is determined by the position the number holds, not by the number itself. Take for example the number 427. Although 7 is thought of as a larger number than 4, we know that the 7 is worth less than the 4 in this instance. Why? Because of its respective position within the number.
Positional number systems and their placement/value of digits work through using a base number with a series of exponents applied to the base. The decimal system has a base of 10, the binary number system has a base of 2, and the hexadecimal number system has a base of 16.
Within the decimal system, it works like this (starting the dissection with the rightmost integer):
|Base and Exponent||103||102||101||100|
427 = (7)(100) + (2)(101) + (4)(102)
= (7)(1) + (2)(10) + (4)(100)
= 7 + 20 + 400
By the way, by definition any number with an exponent of 0 is equal to 1. This is one of those mathematical definitions that we really do not want to have to prove at this moment—just believe it! : )
[If you are really interested, however, take a look at this: When we multiply like bases, we add the exponents. That means 101 * 10-1 = 100. Remember that 101 = 10 and 10-1 = 1/10, so we can check our work by substituting those numbers in the equation that uses the exponents. Indeed, 10 * 1/10 = 1 !]
Notice also that in Base 10 we have ten integers to choose from for filling a position (0-9).
Essentially, we work with some fairly complex mathematical ideas in Base 10. The elementary discussion of the 1s, 10s, and 100s places is not so simple! Let us apply the same principles with the Binary or Base 2 number system (often notated with a subscript 2).
Base 2 or Binary
In Base 2, we have two integers that can fill a position (0,1). Using the Base 10 model as a guide, convert the binary number 11012, again starting the conversion with the rightmost integer or least significant bit):
|Base and Exponent||23||22||21||20|
1101 = (1)(20) + (0)(21) + (1)(22) + (1)(23)
= (1)(1) + (0)(2) + (1)(4) + (1)(8)
= 1 + 0 + 4 + 8
Another way to view binary-to-decimal conversions is to note whether you have the digit 1 or 0 in a spot—just like yes or no (you know—black/white or binary). In the case of 1101, a basic inventory is all that is necessary. Is there a tick mark in the 8s place? Yes (and so on). The trick is to remember the value in each place and remember that 20 equals 1.
When we take a look at any other positional number systems (e.g. ternary (Base 3), octal (Base 8), hexadecimal (Base 16)), we find they work in the same way.
For the purposes of networking, we often refer to octets, or a group of eight binary numbers, with a 1 or 0 in each place from 20 to 27. If a one occurs in each place resulting in the binary number 11111111, the decimal equivalent is 255.
As a point of information (no pun intended), the dot that we so fondly call the “decimal point” is only a decimal point in the decimal system. Its official name is “radix.” Curiously enough, life in positional numbers systems works the same way on both sides of the radix. Check it out!
|Base and Exponent||100||10-1||10-2||10-3|
|| .1 or 1/10
|| .01 or 1/100
|| .001 or 1/1000
|Base and Exponent||20||2-1||2-2||2-3|
|| .5 or 1/2
|| .25 or 1/4
|| .125 or 1/8
What about the Hexadecimal number system?
You guessed it—it is a positional number system, too, with a base of 16. We use 16 symbols in the hexadecimal number system. You are familiar with 0 through 9, so what about the others?
We use A-F to represent the decimal numbers 10 through 16!
A=10 B=11 C=12 D=13 E=14 F=15
|Base and Exponent||163||162||161||160|
Here is an example of a hexadecimal number and its analysis using the earlier method (always start with the rightmost number):
7D4F16 = (15)(160) + (4)(161) + (13)(162) + (7)(163)
= (15)(1) + (4)(16) + (13)(256) + (7)(4096)
Pull out your calculator or spreadsheet if you want to find the total, but the total is irrelevant to understanding the number system. There is one more important basic concept to note. It is not by coincidence that four digits in binary (11112) equals one digit in hexadecimal (F16 or Fh). More on that another day!