The Binary System
It is believed from ancient writings that the Chinese were aware of the binary or two-valued system of numbers as early as 3000 B.C. However, this fact was lost as the years progressed, and Leibnitz thought that he had discovered binary himself almost 5,000 years later. In an odd twist, Leibnitz apprised his friend Grimaldi, the Jesuit president of the Tribunal of Mathematics in China, of the religious significance of binary 1 and 0 as an argument against Buddhism!
A legend in India also contains indications of the power of the binary system. The inventor of the game of chess was promised any award he wanted for this service to the king. The inventor asked simply that the king place a grain of wheat on the first square of the board, two on the second, and then four, eight, and so on in ascending powers of two until the sixty-four squares of the board were covered. Although the king thought his subject a fool, this amount of wheat would have covered the entire earth to a depth of about an inch!
We are perhaps more familiar with the binary system than we realize. Morse code, with its dots and dashes, for example, is a two-valued system. And the power of a system with a base of two is evident when we realize that given a single one-pound weight and sufficient two-pound weights we can weigh any whole-numbered amounts.
At first glance, however, binary numbers seem a hopeless conglomeration of ones and zeros. This is so only because we have become conditioned to the decimal system, which was even more hopeless to us as youngsters. We may have forgotten, with the contempt of familiarity, that our number system is built on the idea of powers. In grade school we learned that starting at the right we had units, tens, hundreds, thousands, and so on. In the decimal number 111, for example, we mean 1 times 102, plus 1 times 101, plus 1. We have handled so many numbers so many times we have usually forgotten just what we are doing, and how.
The binary system uses only two numbers: 1 and 0. So it is five times as simple as the decimal system. It uses powers of two rather than ten, again far simpler. Let’s take the binary number 111 and break it down just as we do a decimal number. Starting at the left, we have 1 times 22, plus 1 times 21, plus 1. This adds up to 7, and there is our answer.
The decimal system is positional; this is what made it so much more effective in the simple expression of large numbers than the Roman numeral system. Binary is positional too, and for larger numbers we continue moving toward the left, increasing our power of two each time. Thus 1111 is 23 plus 22 plus 21 plus 1.
We are familiar with decimal numbers like 101. This means 1 hundred, no tens, and 1 unit. Likewise in binary notation 101 means one 4, no 2’s, and one 1. For all its seeming complexity, then, the binary system is actually simpler than the “easy” decimal one we are more familiar with. But despite its simplicity, the binary system is far from being inferior to the decimal system. You can prove this by doing some counting on your fingers.
Normally we count, or tally, by bending down a finger for each new unit we want to record. With both hands, then, we can add up only ten units, a quite limited range. We can add a bit of sophistication, and assign a different number to each finger; thus 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. Now, believe it or not, we can tally up to 55 with our hands! As each unit is counted, we raise and lower the correct finger in turn. On reaching 10, we leave that finger—thumb, actually—depressed, and start over with 1. On reaching 9, we leave it depressed, and so on. We have increased the capacity of our counting machine by 5-1/2 times without even taking off our shoes. The mathematician, by the way, would say we have a capability of not 55 but 56 numbers, since all fingers up would signify 0, which can be called a number. Thus our two hands represent to the mathematician a modulo-56 counter.
This would seem to vanquish the lowly binary system for good, but let’s do a bit more counting. This time we will assign each finger a number corresponding to the powers of 2 we use in reading our binary numbers. Thus we assign the numbers 1, 2, 4, 8, 16, 32, 64, 128, 256, and 512. How many units can we count now? Not 10, or 55, but a good bit better than that. Using binary notation, our ten digits can now record a total of 1,023 units. True, it will take a bit of dexterity, but by bending and straightening fingers to make the proper sums, when you finally have all fingers down you will have counted 1,023, or 1,024 if you are a mathematical purist.
Once convinced that the binary method does have its merits, it may be a little easier to pursue a mastery of representing numbers in binary notation, difficult as it may seem at the outset. The usual way to convert is to remember, or list, the powers of 2, and start at the left side with the largest power that can be divided into the decimal number we want to convert. Suppose we want to change the number 500 into binary. First we make a chart of the positions:
| Power of 2 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Decimal Number | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| Binary Number | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 |
Since 256 is the largest number that will go into 500, we start there, knowing that there will be nine binary digits, or “bits” in our answer. We place a 1 in that space to indicate that there is indeed an eighth power of 2 included in 500. Since 128 will go into the remainder, we put a 1 in that space also. Continuing in this manner, we find that we need 1’s until we reach the “8” space which we must skip since our remainder does not contain an 8. We mark a 1 in the 4 space, but skip the 2 and the 1. Our answer, then, in binary notation is 111110100. This number is called “pure binary.” It can also lead to pure torture for human programmers whose eyes begin to bug with this “bit chasing,” as it has come to be called. Everything is of course relative, and the ancient Roman might gladly have changed DCCCLXXXVIII to binary 1101111000, which is two digits shorter.
There is a simpler way of converting that might be interesting to try out. We’ll start with our same 500. Since it is an even number, we put a 0 beneath it. Moving to the left, we divide by two and get 250. This also is an even number, so we mark down a 0 in our binary equivalent. The next division gives 125, an odd number, so we put down a 1. We continue to divide successively, marking a zero for each even remainder, and a 1 for the odd. Although it may not be obvious right away, we are merely arriving at powers of two by a process called mediation, or halving.
| Decimal | 1 | 3 | 7 | 15 | 31 | 62 | 125 | 250 | 500 |
| Binary | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 |
Obviously we can reverse this procedure to convert binary numbers to their decimal equivalents.
There is an interesting extension of this process called duplication by which multiplication can be done quite simply. Let us multiply 95 times 36. We will halve our 95 as we did in the earlier example, while doubling the 36. This time when we have an even number in the left column, we will simply cancel out the corresponding number in the right column.
| 95 | 36 |
| 47 | 72 |
| 23 | 144 |
| 11 | 288 |
| 5 | 576 |
| 2 | 1152 |
| 1 | 2304 |
| —— | |
| 3420 |
This clever bit of mathematics is called Russian peasant multiplication, although it was also known to early Egyptians and many others. It permits unschooled people, with only the ability to add and divide, to do fairly complex multiplication problems. Actually it is based on our old stand-by, the binary system. What we have done is to represent the 95 “dyadically,” or by twos, and to multiply 36 successively by each of these powers as applicable. We will not digress further, but leave this as an example of the tricks possible with the seemingly simple binary system.
Even after we have learned to convert from the decimal numbers we are familiar with into binary notation almost by inspection, the results are admittedly unwieldy for human handling. An employee who is used to getting $105 a week would be understandably confused if the computer printed out a check for him reading $1101001. For this reason the computer programmer has reached a compromise with the machine. He speaks decimal, it speaks binary; they meet each other halfway with something called binary-coded decimal. Here’s the way it works.
A little thought will show that the decimal numbers from 0 through 9 can be presented in binary using four bits. Thus:
| Decimal | Binary |
| 0 | 0 |
| 1 | 1 |
| 2 | 110 |
| 3 | 111 |
| 4 | 1100 |
| 5 | 1101 |
| 6 | 1110 |
| 7 | 10111 |
| 8 | 11000 |
| 9 | 11001 |
In the interest of uniformity we fill in the blanks with 0’s, so that each decimal number is represented by a four-digit block, or word, of binary code. Now when the computer programmer wants to feed the number 560 into the computer in binary he breaks it into separate words of 5, 6, and 0; or 0101, 0110, and 0000. In effect, we have changed $5 words into four-bit words! The computer couldn’t care less, since it handles binary digits at the rate of millions a second; and the human is better able to keep his marbles while he works with the computer. Of course, there are some computers that are classed as pure binary machines. These work on mathematical problems, with none of the restrictions imposed by human frailty. For the computer the pure binary system is more efficient than the binary decimal compromise.
The four-digit words can be made to represent not only numbers, but letters as well. When this is done it is called an alpha-numeric or alphameric code. Incidentally, it is conceivable that language could be made up of only 1’s and 0’s, or perhaps a’s and b’s would be better. All it would take would be the stringing together of enough letters to cover all the words there are. The result would be rather dull, with words like aabbababaabbaaba, bbaabbaabababaaabab, and aaaaaaaaabaaa; it is doubtful that the computer will make much headway with a binary alphabet for its human masters.
In the early days of binary computer work, the direct conversion to binary code we have discussed was satisfactory, but soon the designers of newer machines and calculating methods began to juggle the digits around for various reasons. For one thing, a decimal 0 was represented by four binary 0’s. Electrically, this represents no signal at all in the computer’s inner workings. If trouble happened, say a loose connection, or a power failure for a split second, the word 0000 might be printed out and accepted as a valid zero when it actually meant a malfunction. So the designers got busy trying other codes than the basic binary.
One clever result is the “excess-3” code. In this variation 3 is added to each decimal number before conversion. A decimal 30 is then represented by the word 0011 instead of 0000. There is, in fact, no such computer word as 0000 in excess-3 code. This eliminates the possibility of an error being taken for a 0. Excess-3 does something else too. If each digit is changed, that is, if 1’s become 0’s and 0’s become 1’s, the new word is the “9’s complement” of the original. For example, the binary code for 4 in excess-3 is 0111. Changing all the digits, we get 1000, which is decimal 5. This is not just an interesting curiosity, but the 9’s complement of 4 (9 minus 4). Anyone familiar with an adding machine is used to performing subtraction by using complements of numbers. The computer cannot do anything but add; by using the excess-3 code it can subtract by adding. Thus, while the computer cannot subtract 0110 from 1000, it can quite handily add 1001 to 1000 to get the same result.
There are many other reasons for codes, among them being the important one of checking for errors. “Casting out nines” is a well-known technique of the bookkeeper for locating mistakes in work. Certain binary codes, containing what is called a “parity bit,” have the property of self-checking, in a manner similar to casting out nines. A story is told of some pioneer computer designers who hit on the idea of another means of error checking not as effective as the code method.
The idea was clever enough, it being that identical computers would do each problem and compare answers, much like the pairs of abacus-wielders in Japan’s banks. In case both computers did not come up with the same answer, a correction would be made. With high hopes, the designers fed a problem into the machines and sat back to watch. Soon enough a warning light blinked on one machine as it caught an error. But simultaneously a light blinked on the other. After that, chaos reigned until the power plugs were finally pulled. Although made of metal and wires, the computers demonstrated a remarkably human trait; each thought the other was wrong and was doing its best to change its partner’s answer! The solution, of course, was to add a third computer.
Binary decimal, as we have pointed out, is a wasteful code. The decimal number 100 in binary decimal coding is 0001 0000 0000, or 12 digits. Pure binary is 1100100, or only 7 digits. By going to a binary-octal code, using eight numbers instead of ten, the words can be 3-bit instead of 4-bit. This is called an “economy” code, and finds some application. There are also “Gray” codes, reflected binary codes, and many more, each serving a particular purpose. Fortunately for the designer, he can be prodigal with his use of codes. With 4-bit words, 29 billion codes are available, so a number of them are still unused.
Having translated our decimal numbers into code intelligible to our computer, we still have the mathematical operations to perform on it. With a little practice we can add, subtract, multiply, and divide our binary numbers quite easily, as in the examples that follow.
| Addition: | 1100 | (12) |
| 0111 | ( 7) | |
| —— | —— | |
| 10011 | (19) | |
| Subtraction: | 1010 | (10) |
| - 0010 | ( 2) | |
| ——— | —— | |
| 1000 | (8) |
| Multiplication: | 0110 | (6) |
| × 0011 | (3) | |
| ——— | –—— | |
| 0110 | ||
| 0110 | ||
| 0000 | ||
| 0000 | ||
| ——— | ||
| 10010 | (18) | |
| TN1 Division: | 1010 ÷ 10 = 0101 | (10 ÷ 2 = 5) |
The rules should be obvious from these examples. Just as we add 5 and 5 to get 0 with 1 to carry, we add 1 and 1 and get 0 with 1 to carry in binary. Adding 1 and 0 gives 1, 0 and 0 gives 0. Multiplying 1 times 1 gives 1, 1 times 0 gives 0, and 0 times 0 gives 0. One divides into 1 once, and into 0 no times. Thus we can manipulate in just the manner we are accustomed to.
The computer does not even need to know this much. All it is concerned with is addition: 1 plus 1 gives 0 and 1 to carry; 1 plus 0 gives 1; and 0 plus 0 gives 0. This is all it knows, and all it needs to know. We have described how it subtracts by adding complements. It can multiply by repetitive additions, or more simply, by shifting the binary number to the left. Thus, 0001 becomes 0010 in one shift, and 0100 in two shifts, doubling each time. This is of course just the way we do it in the decimal system. Shifting to the right divides by two in the binary system.
The simplest computer circuitry performs additions in a serial manner, that is, one operation at a time. This is obviously a slow way to do business, and by adding components so that there are enough to handle the digits in each row simultaneously the arithmetic operation is greatly speeded. This is called parallel addition. Both operations are done by parts understandably called adders, which are further broken down into half-adders.
There are refinements to basic binary computation, of course. By using a decimal point, or perhaps a binary point, fractions can be expressed in binary code. If the position to the left of the point is taken as 2 to the zero power, then the position just to the right of the point is logically 2 to the minus one, which if you remember your mathematics you’ll recognize as one-half. Two to the minus two is then one-fourth, and so on. While we are on the subject of the decimal point, sophisticated computers do what is called “floating-point arithmetic,” in which the point can be moved back and forth at will for much more rapid arithmetical operations.
No matter how many adders we put together and how big the computer eventually gets, it is still operating in what seems an awkward fashion. It is counting its fingers, of which it has two. The trick is in the speed of this counting, so fast that one million additions a second is now a commonplace. Try that for size in your own decimally trained head and you will appreciate the computer a little more.