Understanding Number Systems
This is a somewhat technical subject, but it is one that will come in handy when you are working with computers, so stick with me through this article and you will understand number systems. I taught this subject to Army officers when I was on active duty many years ago, and I still remember it well. I was able to get it across to my students, and I can do the same for you if you will concentrate on it with me. I recommend that you work the problems to fully understand the subject.
The number system we are taught and with which we deal daily in our lives is decimal. The base of this number system is 10. We are taught early that the positional values for this number system are ones, tens, hundreds, thousands, etc. We are taught this by rote, but we are not taught the rule on how to calculate them. But that is easy. Number systems always start with the ones position. The positional value to the left of one will be one times the base of the number system or ten (1 X 10 = 10). The next positional value to the left will be that positional value times the base of the system or 100 (10 X 10 = 100). This is how the ones, ten, hundreds, thousands are calculated.
Each number system has one character multiplier values in it that range from zero to one less than the base of the number system. In decimal, the multipliers are 0 - 9.
When we look at the number 123, we just accept it as the decimal value, but in number system theory, it is the sum of all multipliers times the positional value for the multiplier. Follow this example:
3 X 1 = 3
2 X 10 = 20
1 X 100 = 100
Add up the numbers to the right of the equal signs (3 + 20 + 100) and you get 123.
You have heard that computers use binary. This is because in electrical circuits there is an on or on off value (two possible values). The base for binary is two (2). Follow the rule for multipliers that they will be from 0 to one less than the base of the system so the multipliers for binary are zero and one.
Follow the rule for determining the positional values for the system. Start at one and multiply it by the base (two) so the position to the left of the one position is two (1 X 2). The next position to the left is the two position times the base (2) or 4 (2 X 2). The next position to the left is the four position times two (4 X 2) or 8. Here are the first few positional values in binary:
256 - 128 - 64 - 32 - 16 - 8 - 4 - 2 - 1
Notice that each position is doubled the value to its right. This makes sense since the base is two and we are multiplying each positional value by two to get the value of the next position to the left.
Letís look at this binary number.
To convert this to decimal, we multiply the positional value by the multiplier.
1 X 1 = 1
1 X 2 = 2
0 X 4 = 0
0 X 8 = 0
1 X 16 = 16
Now add up the values to the right of the equal sign and we get 19 decimal for the binary number 10011.
What is the decimal value of 111 binary? If you got 7 decimal then you understand how binary works.
1 X 1 = 1
1 X 2 = 2
1 X 4 = 4
1 + 2 + 4 = 7
Convert one more binary number - 1000000. If you got 64 decimal, you are right.
A weakness of binary is that it takes so many positions to express a large value. To get around this, the hexadecimal base system was devised. This is the base 16. We abbreviate hexadecimal as "hex".
Since we said earlier that the multipliers for the system were zero to one less than the base of the system (16), how can we get one position multipliers when we only have 0 - 9 as numeric numbers? Well, we use the first six letters of the alphabet for the multipliers above nine. Here are the multipliers in hex.
OK, now stick with me and remember the rules for number systems. The positional values start with one and are determined by multiplying the base by the number to get each succeeding positional value from right to left.
The first positional value is one. The next one to the left is 16 (1 X 16). The next one to the left is 256 (16 X 16). The next one to the left of 256 is 4,096 (256 X 16). The next one to the left of 4,096 is 65,536 (4,096 X 16).
The first few positional values of hex are:
1,048,576 - 65,536 - 4,096 - 256 - 16 - 1
You can see that we can express a very large number in hex with fewer positions than we can in our standard decimal numbering system.
Letís convert a few hex numbers to decimal. Convert hex 1F to decimal. Just follow the rule and multiply the positional value by the multiplier.
F (=15) X 1 = 15
1 X 16 = 16
Add 15 and 16 and the number 1F in hex is 31 in decimal.
Convert 2AB hex to decimal. Just follow the rule. Remember, multiply each positional value by its multiplier.
B (=11) X 1 = 11
A (=10) X 16 = 160
2 X 256 = 512
Add up the values to the right of the equal signs and you find that 2AB in hex is 683 in decimal.
Why learn hex? In some instances when you are writing HTML for web pages, hex numbers are used. A two position hex number will express a number from 0 (hex 00) to 255 (hex FF). Since zero is a number, this will give 256 total values.
Another reason that hex is used is that each four positions of a binary number can be expressed in one hex position so it is much easier to write a large number in hex than in binary.
Letís look at the binary value 1111. If you use the rules, this will be 1+2+4+8 = 15. This can be written as "F" in hex. (the multiplier "F" in hex is equal to decimal 15.
Letís convert another number in binary to hex. Start at the ones position and break the binary number into four position groups. Express each four position group as its hex value
Binary 1011 1100 1001 0111
Hex B C 9 7
To double check that the two are equal follow the rules and convert both number systems to decimal. If you came up with 48,279 you are right.
Octal was used in computers until the hexadecimal numbering system was invented and "hex" has largely replaced it, but you may still run into situations where the octal numbering system is still used. Just remember the rules from this article and you will have no problem understanding it.
Copyright 2006 John Howe, Inc.
About the Author: John V. W. Howe is an entrepreneur, author, inventor, patent holder, husband, father, and grandfather. He has been involved in entrepreneurial activities for over 40 years. He founded www.boomer-ezine.com and www.retirement-jobs-online.com to help Boomers (baby boomers) become entrepreneurs when they retire.