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.