Lets look at the 32 bit number we had at the end of the Binary Numbering System Page:
Now that looks like a pain to say or to write. Lets see if we can come up with something a little easier to handle.
Lets group this by cutting it up into bite (no... not that kind of byte!) sized chunks. Lets group it into groups of 3 bits per group. Now we can write the number “telephone number” style:
Notice, like everything else we have done with computer math I started at the right and worked to the left while doing this grouping. So now we have 10 groups of 3 digits and 2 digits left over. What is the big improvement?
Remember when we were working with 3 bits and were introducing how to count in binary. We produced a table like this:
Now lets replace each of the groups above with the "decimal" digit equal to the value in the group.
After throwing out the spaces it becomes: 23474127525.
This number is not the same as Twenty-three-trillion-four-hundred-seventy-four-million-one-hundred-twenty-seven-thousand-five-hundred-twenty-five!
The reason is that the highest digit we can have is 7 in this numbering system.& In this system there are 8 types of digits and they run from 0 to 7. Since there are 8, types this system is called OCTAL. Other names for this numbering system are "base 8" or "radix 8"
The official way octal is written is: 234741275258.
The small 8 says that this number is written in base 8 or OCTAL.
Another form used for this system is the short hand used in many
computer languages. 0x23474127525.
The 0x at the start indicates this is an OCTAL Number.
The numbering system we have all grown-up using is called the decimal system. In the decimal system there are 10 digits and these run from 0 to 9. This is about all I will say about this system for now. However, I will use it as well as the binary, octal, and Hexadecimal system in examples in the next section, Generic Radix Numbering System
Again we will use our 32 bit number, but this time we will split it up into groups of 4 bits. So now it becomes:
Now we will create a table by counting all the 4 bit number possibilities.
UH OH .... WE HAVE A PROBLEM!!!! 10 IS NOT A DIFFERENT SYMBOL!
10 is a combination of two symbols already used! We need a new symbol and we will use an "a" for this place marker. Continuing with our table we have:
Replacing the groups of four with our new symbols gives:
Removing the spaces this becomes: 9cf0af55H. The small H indicates HEXADECIMAL or commonly called HEX. This is a base 16 numbering system. Many computer languages represent this with a # sign proceeding the characters. Normally, uppercase or lower case representation of the alphabetic characters is acceptable.
At this point I have two choices:
1: give you more theory
2: show you where this might be useful.
My guess is your up to your neck in theory at this point and you are wondering: "Is this ever useful?"
On your browser, somewhere up in the menu items, probably under "file"
or "view" you will find a sub menu item called "view-source". Once you view the source used to create the web page you may find near the start of the web page some definitions such as:
<body bgcolor="#FFFFFF" > AND <font color="#333333">.
Those are the colors of parts of the web page layout and those are defined in HEX. There are 3 groups of 2 HEX numbers standing for the colors Red, Green, & Blue used to light up your screen. Sorry, the page you are viewing is pretty boring with bgcolor = #FFFFFF (all full on... = white) and font color #000000 (all off = black).
In UNIX & LINUX files are given "modes" which is basically
permission codes. It might looks something like this:
.RWXR.XR..
This can be divided into 3 sections of symbols RWX
RWX RWX. In each section: R= Read permission, W = Write Permission &
X = eXecute permission.
The first section is the individual who is the owner of a file. The second section of three represents the user group the owner is a member of and the third section represents "others"
If R is given a value of 4, W = 2 and X = 1. We might give a file the mode value of 755 by typing chmod 755. This would mean the owner has RWX and the group and others have only RX permissions. Guess what? We just talked OCTAL!
Every letter of the English Alphabet is assigned a number. This can be found by looking at an ASCII table. For Example: a table displaying all of the ASCII codes. Notice the table has the codes displayed in HEX and OCTAL as well as normal decimal. In some cases the OCTAL or HEX is easier.
For example A = 65 decimal and a = 97 so small letters are 32 higher in the decimal system. In HEX A= 41 and a = 61 just add 2 to the greatest digit!!!! A whole lot easier!
OCTAL works the same way. A = 101 and a = 141 so just add 40 to it.
Why do all these systems exist? Binary exists because it is the natural language of the computer
For example, you will probably want to set "flags" in a program or script file
someday. Flags are just binary values, but these sometimes have to be
combined. For example:
Let's say you have looked at lots of vehicles and you want to
summarize. Maybe you want a flag for car or truck so CAR =
1 if a car, and CAR = 0 if a truck. Maybe you only like Red but
would accept other colors if the price is right. Say RED = 1 and
RED=0.
Guess what? If we combine these two facts we have 4
possibilities and a binary numbering system.
Octal exists mostly because it was the first short hand way used. Most of the "legacy" languages use OCTAL... but these "legacy " languages include things such as C and the son of C, C++.
HEX often makes a lot of sense. A HEX digit is 4 bits and two of these make a BYTE. (It is not an official term, but is commonly used that 1/2 of a BYTE is a NYBBLE or 1 hex digit worth.) Computer systems seem grow in groups of 8. Microprocessor based computers of the late 70's and early 80's were 8 bit based machines. The first IBM PC machines caused the market to explode with 16 bit machines. Later the 386 based machines came out based on 32 bits. Now there are some computer systems running 64 bits. HEX seems the natural way to define data used by these machines. (More detail about what a "XX bit" machine will be found in the Memory and CPU pages).