While we say that computers store numbers, we are technically not being accurate. A computer is still essentially a machine. It deals with electronic impulses. The only thing today's computers really understand is fluctuations in electronic voltages. The computer can recognize two values, high and low. These values are also sometimes referred to as on or off, true or false, yes or no. The term binary is often used to describe this kind of behavior as well.
Any mechanical device that exhibits this yes/no behavior is referred to as a switch. We are already comfortable with the notion of switches for lights and other devices. A computer is essentially a huge number of switches. A computer science might refer to them as binary switches, indicating they allow only two possible values apiece.
One huge advantage of this type of switch is the capability for self - correction. Voltage is actually an analog property, but forcing the circuitry to accept it as one of two values makes the computer a digital system, and minimizes the possibility of mistakes due to external changes in voltage. This characteristic is the main reason computers use binary notation. It is very easy to build self-correcting circuits using binary switches. What that really means to us is that computers can be highly accurate digital devices, even though they still use a form of analog signaling deep within their structure.
It doesn't seem possible that a switch - based system could hold enough information to be usable, but it can. Imagine your instructor has developed a code for your class: When you come into the lecture room, if the lights are on, the class will meet. If the lights are off, the class will be cancelled that day. (NOTE: this is ONLY an example!) With one switch, your instructor can send you two possible messages: On = class today, Off = no class. Imagine you have a class with lab and lecture components. This one-switch system cannot tell you about both the lab and lecture sessions. However, if the lecture room has two banks of lights, for example one in the front of the room and one in the back, the number of messages possible could be doubled. For example, let's say the front lights represent whether the lecture will meet, and the back lights represent the likelihood of a lab session. We now could send four messages:
| front switch | back switch | meaning |
| OFF | OFF | No class, no lab |
| OFF | ON | No class, but lab |
| ON | OFF | Class, but no lab |
| ON | ON | Both will meet |
NOTE: Put drawings of light switches in here. It would be more effective, I think... -ajh
This seems like a very small capability, and it is. But these on/off impulses can be combined in a simple scheme to represent numbers. Once we can represent numbers, we have a digital machine. As you have seen, digital machines can do many interesting things with great accuracy. Everything computers do is based on the idea of on/off impulses representing numbers.
If we take the table above and agree to some conventions, we can make it more general. Let's say we represent a switch with a 1 if it is on and a 0 if it is off. Let's also agree to define a bank of switches as a series of digits written together. For example, 1000 means we have four switches, and only the first one is on. All the rest are off. Using these conventions, we can re-write the above table like this:
| Value | Message Number |
| 00 | 0 |
| 01 | 1 |
| 10 | 2 |
| 11 | 3 |
Using this kind of scheme, we could arbitrarily assign values to different combinations of switches. As long as we are willing to keep adding switches, we can store any number of messages simply by using switches.
We can get numbers from on-off signals if we review some simple mathematics. (Don't worry, we're not going to do anything fancy here!) We are used to thinking of numbers in base 10. This is so natural to us that we sometimes forget that base 10 is an arbitrary way of representing numbers. People did mathematical calculations for thousands of years using other bases. Base 10 is simple enough that we rarely think about needing to use other bases, but it is not the only way to do math.
Let's review what it means to represent numbers in base 10.
If I have a number, say 345, what does that number really mean? It means I have 3 times 100 plus 4 times 10 plus 5 times one. That seems pretty obvious, but how did we get the 100, 10, and one? These values are all based on powers of 10. 100 is 10 squared (in computing, we often refer to exponents with the caret symbol(^), so 10 to the second power is 10^2.) 10 is 10^1, and 1 is 10^0. (remember, any number raised to the zero power is 1) While we're discussing math notation on computers, you should know that multiplication is usually denoted by an asterisk (*). This avoids confusion with the X or x symbols. The second sentence in this paragraph could be re-written like this: It means I have (3*100) + (4*10) + (5*1).
The number 345 can be summarized like this:
| 3*10^2 +.. | 4*10^1 +.. | 5*10^0 |
| 3*100 +.. | 4 * 10 +.. | 5 * 1 |
| 300 +.. | 40 +.. | 5 |
In other words, the values of the digits are all based on powers of 10. With one digit, we can describe up to 10 different values. If we have two digits in base 10, we have 10 * 10 possible values we can describe (100). If we have three digits in base 10, we can describe 1000 (or 10 * 10 * 10) different values. Each additional digit increases the number of values we can describe by a factor of our base (10 in our normal counting system). We can describe any number using base 10, but we can also describe any number using any other base.
We don't have to base a numbering system on 10. (The Sumerians based their system on 60. We still have 60 minutes in an hour.) We simply use 10 because we have 10 fingers on our hands. It makes sense to us. Remember that the computer tends to see things in terms of on or off, yes or no. The most natural number for the computer to count with is two. Computers can represent any number, but they represent these numbers in terms of two.
The binary system is base two. It works just like base 10, but rather than using powers of 10 as its foundation, it uses powers of two. The rightmost digit in binary represents 2^0, or the ones digit, anything raised to the zero power equals one.) The next digit to the left represents 2^1 or the twos digit. The next digit to the left represents 2^2, or the fours digit. Each successive digit doubles the number of possible values. (Sound familiar?) Examine the following table to see how numbers are stored in binary notation.
| Decimal Value | Binary Value | 2^3 | 2^2 | 2^1 | 2^0 |
| 8s | 4s | 2s | 1s | ||
| 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
| 2 | 10 | 0 | 0 | 1 | 0 |
| 3 | 11 | 0 | 0 | 1 | 1 |
| 4 | 100 | 0 | 1 | 0 | 0 |
| 5 | 101 | 0 | 1 | 0 | 1 |
| 6 | 110 | 0 | 1 | 1 | 0 |
| 7 | 111 | 0 | 1 | 1 | 1 |
| 8 | 1000 | 1 | 0 | 0 | 0 |
![]()