Computers for Smart People by Robert S. Swiatek - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

22. Base systems

 

            Computers use a variety of different number base systems to operate, including the familiar base 10. In addition, binary or base 2, octal or base 8 and hexadecimal, which is base 16, are also used. If you are going to get an appreciation of just how computers work, you will need some comprehension of the different number systems. We will begin by doing some counting in all four of these bases.

            We will count in each from 0 to 23 and we shall start with the familiar base 10. If you have a PC, access the calculator on your system by clicking on start and then go up to programs. From there go to accessories and then click on calculator. Once there, click on view and change your calculator to scientific and you should be in base 10 or decimal. If not, set the calculator to that base by turning on

            Dec

from the four choices Hex, Dec, Oct, and Bin. If the last choice is Bin Laden, call the FBI. You are now ready to begin counting. If you don’t have a PC, you may be able to accomplish the same results with an ordinary calculator by doing the following:

            click on 0, then +, then 1 and then =.

The result will be 1. If you then repeat clicking on the = sign, you will get the same result as if we were counting from 0 to 23. The result from your PC’s calculator, your ordinary calculator, or if you have neither should be

            0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23.

This is what we expect to get if we were to count from 0 to 23 in that familiar number base 10.

            Now we shall repeat the process for binary or base 2. First set the PC calculator to base 2 by turning on the switch for

            Bin.

Proceed as before and the result will be

            0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 10001       10010 10011 10100 10101 10110 10111

and this is counting from 0 to 23 in base 2. Again if you don’t have the scientific calculator, take my word for it and I will return to these numbers shortly.

            We will now repeat the process for octal and hexadecimal. Switch on base 8 by setting the calculator to

            Oct

and repeat the process as before. The result will be

            0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20 21 22 23 24 25 26 27

and that list represents counting from 0 to 23 in base 8. Next set the calculator to base 16 by clicking on

            Hex

– don’t worry, nothing bad will happen to you – and by once again repeating the exercise, the result is

            0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17.

This is the sequence of numbers you get if you count from 0 to 23 in base 16 or hexadecimal.

            If you are puzzled by this, don’t be, as I will attempt to clarify these sequences above. To begin, note that counting in base 10 involves the 10 symbols 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. The number 23 in base 10 has 2 and a 3, where the 2 represents 10s and the 3 represents units or 1s. If we consider the number 328 in base 10, the 3 stands for hundreds or 10 x 10, the 2 represents tens and the 8 stands for units. Hundreds, tens and units are all powers of 10 as the hundreds represent 10 to the second power, the ten represents 10 to the first power and unit represents 10 to the zero power. Any positive whole number to the zero power is 1, whether it be 10, 16, 8 or 2. Trust me.

            This you may have learned in math when you studied powers of numbers. If you missed that class a quick lesson in factors and powers should convince you of this. Powers of a number are nothing more than the number of times it is used as a factor. Thus

            10 x 10 x 10

uses 10 as a factor three times or we could say that this represents

            10 to the power of 3,

or

            10 to the 3rd power.

If we divide

            10 x 10 x 10

or

            10 to the 3rd power

by

            10 x 10

or

            10 to the 2nd power,

the result is 10 since we are dividing 1000 by 100 and we know that the result is simply 10. You may have also learned that you could accomplish the division by merely subtracting the exponents or powers of 10. In this case we would subtract 2 from 3 giving 1 and we would still come up with 10, or 10 to the 1st power.

            With that in mind, consider dividing

            10 x 10 x 10

by

            10 x 10 x 10

or

            10 to the 3rd power

by

            10 to the 3rd power.

Subtracting the exponents 3 from 3 gives 0 or our answer is

            10 to the 0 power.

But we know that 1000 divided by 1000 is equal to 1 which illustrates that

            10 to the 0 power

is equal to 1. Didn’t I tell you? If we did a similar division using a 6 rather than the 10 you could see that any positive number to the 0 power will be equal to 1. Note however that 0 to the 0 power is not equal to 1!

            This brings us back to our number 328, which is

3 x 10 to the 2nd power + 2 x 10 to the 1st power plus 8 x 10 to the 0 power

or

            300 + 20 + 8.

This will be the makeup of our number in base 10 and it will apply to any number we can consider in the decimal system. But the same makeup will apply to other bases, whether it is base 2, base 8, base 16 or base 62 for that matter.

            Looking at our process of counting from 0 to 23 in the other three bases, you may have noticed the makeup of each of these number systems. Base 2 has only two elements, 0 and 1 while base 8 uses the 8 elements 0, 1, 2, 3, 4, 5, 6 and 7. Finally hexadecimal needs 16 characters so we have to add a few more that are not familiar to us, namely A, B, C, D, E and F. The A would be the equivalent of 10 in base 10, B would stand for 11, C would represent 12 and you can figure out the other 3 symbols. Thus base 16 uses in order the 16 elements

            0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F.

If we were to think of a base 62 system, you might realize that we need 62 symbols and we might use the 10 familiars numbers 0 through 9, the capital letters of the alphabet and lower case letters and we would have our 62 elements. We won’t get into this system but you can see how different bases systems rely on different combinations of symbols.

            Let us now look at three numbers, one in each of our other base systems. These are

            10111 (base 2),

            27 (base 8)

and

            17 (base 16).

These are all equivalent or equal to 23 in base 10.

            10111

can be broken down into

            1 x 2 to the 4th power +

            0 x 2 to the 3rd power +

            1 x 2 to the 2nd power +

            1 x 2 to the 1st power +

            1 x 2 to the power of 0.

This gives us

            16 + 0 + 4 + 2 + 1 = 23.

The number in base 8 of 27 can be broken down into

            2 x 8 to the 1st power +

            7 x 8 to the power of 0.

This translates into

            16 + 7 = 23.

Lastly our number in hexadecimal of 17 is equivalent to

            1 x 16 to the 1st power +

            7 x 16 to power of 0.

This also becomes

            16 + 7 = 23.

You can translate back and forth between the different number bases on the scientific PC calculator by entering 23 in base 10 and then switch to binary, octal or hexadecimal. This will work for larger numbers as well.

            You may wonder what advantage there is to using base 16 or base 2. Obviously binary involves only two symbols, 0 and 1 which can be translated into off or on in a computer. This represents whether a current in a circuit is flowing or not. The disadvantage to base 2 is that numbers would require more digits to capture the number 23, or just about any other number, for that matter. Note that we could have a larger number in hexadecimal stored with fewer digits than in base 10. So there are advantages and disadvantages of each base system. It may not be obvious but you can readily translate a number from binary to hexadecimal without much trouble. I should say the computer can do that, not us humans.

            Though we are more familiar with counting in base 10, we should have a little knowledge about how other base systems work. Fortunately there are scientific calculators that can come to our rescue. With this small treatise, there should be more understanding when we do use the calculator and other base systems. In addition, it now might make a bit more sense as to what all that garbage is that shows up when we get a dump from a computer program. We may not understand it, but we will know that all those numbers represent working storage in hexadecimal or base 16.

Computers can do a lot for us, but can they rule the world? I wouldn’t bet the ranch, even if I owned one. As I mentioned in the discussion on heuristic learning, programs are all designed by people, using strategies created by individuals. I know, some human beings rule the world – a few not very well. Others want to rule. I once designed a computer program to create another program that would produce reports. The former required input on the part of the person who wanted the report. Since reports are so different from one another, I wondered if all the extra effort was really worth it.

Many people talk about this computer replacing human beings, but I’m not convinced. When a computer can experience emotions such as joy, love, fear and sorrow – and even hate – I’ll be concerned about the robots. A more recent example to back up my feeling can be observed now when you call a corporation, wanting to talk to a person. Instead, you talk to a smart computer. Maybe that word in italics is similar to the meaning in our youth when a parent responded to us, “Don’t get smart!” I don’t think we have any worries for the present, especially when the computer asks us a question requiring only a yes or no reply. When we reply no, the computer retorts, “I don’t understand you.” Do you think we should have responded with nyet? Obviously, the system needs some work.