Numbering Systems and Code Sets

Numbering Systems

A numbering system is a set of digits used for mathematical operations such as counting, adding, subtracting, dividing and multiplying. The numbering system that we are all familiar with is called decimal. Decimal is called a base 10 numbering system because it uses 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9). Let's now go (way) back to basics and look at a decimal number 182. From our elementary math schooling, each digit in a decimal number is in a particular column. This "column placement" as we shall call it is fundamental to any numbering system whether it is base 10 (decimal) or something else. The 2 is in the ones column, the 8 in the tens column and the 1 in the hundreds column. We could break the number out as follows:

which would give us:

Another way of determing the values for each column is by using exponents of the base numbering system. For example, 10 to the 0 power equals 1, the 1's column. 10 to the power of 1 equals 10, the 10's column, 10 to the power of 2 equals 100, the 100's column and so on. Be sure that you understand this basic math methodology to column placement before moving on.

Now when we count in decimal, we generally don't start with zero because it is implied, but in this case we will show it for completeness. So we count then as follows:

and so on.

Now notice that when we got to 9, our next number had to use the next column to the left, the 10s column (10 to the power of 1). When starting a new column, the first number we start with is always 1 and the first number to the right of the 1 will always be a zero. This may seem obvious at first, especially with our most familiar numbering system decimal, but keep this concept in mind when working in other numbering systems as we will be shortly.

You're probably thinking, "Gee this is just wonderful, what else do you have for us Einstein?" Well, let us now consider a different numbering system. One that is fundamental to all computer technology. This numbering system in question is called Binary. Binary is a base 2 numbering system which means it uses only 2 digits (zero and one). Let's see how one might count using this numbering system:

and so on.

It may seem strange at first, even tedious, but this is how to count in binary. The concept of column placement we demonstrated using the decimal number 182 remains with binary numbers. Let's use an example binary number like 10110110. This probably means nothing to you at first glance, but if we dissect it using our knowledge of column placement, we put this binary number into a more meaningful context.

Let's first start by figuring out the values of each column for this 8 digit binary number. Working from right to the left, the first column is the 1's column (in any numbering system, the rightmost column is always the 1's column). Now how do we figure out the values for the remaining columns? Answer this question, how many digits are we using in the binary numbering system? Two. Earlier we learned that column placement values can be known by using exponents of the base number. 2 to the power of zero is one or the 1's column which we already knew (any number to the power of zero is always 1). 2 to the power of 1 is 2 (any number to the number of 1 is that number). 2 to the power of 2 is 4 (2 x 2 = 4). 2 to the power of 3 is 8 (2 x 2 x 2 = 8). We will eventually end up with the following column values, from largest to smallest: 1's, 2's, 4's, 8's, 16's, 32's, 64's, and 128's.

Now we can use some math to figure out what the binary number equals in decimal form. Although a technique which probably seemed silly before, let's multiply each number in each column by it's column placement value:

which would give us:

Cool! You've just done your first binary to decimal conversion, congratulations! Using these techniques, you could convert any numbering system to decimal. This would certainly come in handy if you ever meet an extra terrestial who has 3 fingers and thus uses a base 3 numbering system. A more practical application would be to use these techniques on another numbering system that is widely in use in the computer world. This system is hexademical.

The hexadecimal numbering system is a base 16 numbering system. Some people refer to this numbering system simply as "hex". The 16 digits used in hex in order from smallest to largest are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Now what are those letters doing in there?! Simple, we don't have any single digit past 9 so we just use the first 6 letters of the alphabet as digits. This means that A is 10 in decimal and F is equal to 15 in decimal. If you're still awake, perhaps you can figure out what B6 in hexadecimal equals to in decimal?

If you said 182, good guess. If you actually used our previous techniques to figure it out by hand, then you obviously are becoming a master of numbering systems. For those who need a little guidance, here is the math:

which would give us:

Again, the rightmost column is the 1's column, and the value for the next column is the base number to the power of 1, or simply the base number itself, in this case 16. B is really 11 in decimal, which is why B x 16 equals 176. The rest is basic (decimal) math from grade school days.

You may never count in binary, convert a hex number to decimal or meet E.T., but by understanding these concepts you can begin to understand how computers and in turn networks really work at a very fundamental level.

Before moving on to some actual data communications, let's first ask ourselves why we use binary and hex numbering systems with computers at all? What's wrong with the decimal numbering system? The problem lies in how a computer operates at the physical level. Working with electricity and electrical current, computers can represent two states and two states only at their most basic level. Think of the standard light bulb that is either on or off. Power is either causing the light bulb to shine (on) or the lack of power means darkness (off). Computers work with these on and off's of electricity, two states that we represent using ones and zeroes.

Hex is actually a numbering system that computers know nothing about. Hex was created and used as an easier representation for programmers. You may think there's nothing easy about a number such as F8A2 but it is a little easier to work with than all the 1's and zero's it represents. Hex is also convenient because one hex digit represents 4 binary digits (bits). In the world of computers where we talk in bytes (which commonly refers to a group of 8 bits) at a time, 2 hex characters can easily represent one byte. In the next section on code sets this concept will hopefully make more sense in case you're a little confused.

Code Sets

With computers using the binary numbering system for representing data, we need to find a "code set" that can correlate an alphabet, numbering system and character set to the computer's ones and zeroes. Chances are you have heard of one popular code set that was been in use for over 100 years. Here's a hint, dots and dashes. That's right, Morse code. Before there were telephones, people could send a "wire" to another city by way of a Morse code operator. Morse code operators send signals to the other end using a binary system. Instead of ones and zeroes, they used dots and dashes. A dot was represented with a quick tone while a dash was a longer tone. The message SOS for example could be represented as follows: ... - - - ...

The Morse code set was a scheme that matched a certain combination of dots and dashes to the alphabet, numbers zero thru nine and some special characters. With computers, we use a similar system of code sets not unlike Morse code. One of the most popular code sets is called ASCII (American Standard Code for Information Interchange). The ASCII code set uses a combination of 8 binary digits (bits) to represent the english alphabet, the ten digits of the decimal numbering system and a number of special characters. Originally ASCII was defined as a 7 bit code set, but later expanded and sometimes referred to as Extended ASCII. With 8 bits (a combination of 8 ones and zeroes) you can come up with 256 unique combinations to represent all kinds of characters we humans might want the computer to represent.

In Figure 1 below you will find a table of the extended ASCII code set. A brief explanation of the column and row headings is necessary. Along with the human readable ASCII chacters in the table, you are given the values for the characters as they would be represented in binary, hexidecimal and decimal. The binary numbers along the top row represent the 4 low order bits for the characters below. The first column of binary numbers along the left are the 4 high order bits. To get the complete 8 bit number for the ASCII character, you put the lower order bits onto the end of the high order bits. For example, find the lower case letter 'k' in set. Go all the way over to the left of the 'k' and write down the 4 binary numbers for it's row. Now go all the way up from 'k' and write the binary digits for it's column. If you place the first 4 bits in front of the second set of 4 bits you wrote down, you should end up with a binary number of '01101001'. That binary number is the combination of bits a computer uses to represent the lower case 'k'. At least when the computer knows to use the ASCII code set.

Figure 1
ASCII Code Set

Figuring out what the hex number for each character in the table is can be found in a similar fashion. However, determing the the decimal equivalent for each character is a little different. You have to add the column's decimal number to the row's decimal number. Let's do a quick test. What are the binary, hex and decimal numbers that are associated with the ASCII character '#'? If you said 00100011, 23 and 35, you are correct. One last tip, people usually pronounce ASCII as "ASK-ee".

There are other code sets you may come across. One that's used primarly on IBM mainframes is EBCDIC (Extended Binary Coded Data Interchange Code). I think the person(s) who came up with that acronym went to the Redundancy School of Redundancy! The EBCDIC code set uses a different combination of 8 bits to represent various characters. It is not compatible with ASCII. It is usually pronounced "EB-suh-dick".


Goto John Kristoff's Home Page

Last updated: September 14, 1999