Ok, so I know that the alphabet of computers consists of only two symbols, or states: zero and one.
I also seem to understand how computers count beyond one even though they don’t have symbols for anything above one.
What I do NOT understand is how a computer knows* that a particular string of ones and zeros refers to a number, or a letter, or a pixel, or an RGB color, and all the other types of data that computers are able to render.
*EDIT: A lot of you guys hang up on the word “know”, emphasing that a computer does not know anything. Of course, I do not attribute any real awareness or understanding to a computer. I’m using the verb “know” only figuratively, folks ;).
I think that somewhere under the hood there must be a physical element–like a table, a maze, a system of levers, a punchcard, etc.–that breaks up the single, continuous stream of ones and zeros into rivulets and routes them into–for lack of a better word–different tunnels? One for letters, another for numbers, yet another for pixels, and so on?
I can’t make do with just the information that computers speak in ones and zeros because it’s like dumbing down the process human communication to the mere fact of relying on an alphabet.
In: 264
The most basic logical operations are the booloean logical gates. Those are the core of all computing. And they can also be hardwired with actual cables. Let’s say the “AND” gate is when you want something to happen if other two things happen. For example you want a lamp to turn on, if both the dog and the cat are at home. Let’s say you have a dog sensor and a cat sensor and they both give an electric signal and your lamp is wired in a way that it turns on only if both sensors are on. If you check the lamp and it’s on, you know that both animals are at home, otherwise either or both of them are out.
An “OR” gate is when either input is enough to turn the light on. You can also hardwire it and you can make the previous setup a bit different, because now the light will be on if either one of them is at home, but as well if both of them are at home.
A “XOR” gate is a such lamp but now it’s on only if exactly one animal is at home. If both are out or both are in, the lamp is off.
So you can physically wire the two sensors together with the lamp, and add switches here and there in a way that if this and this and this switches are on, then it works as an AND loop, but if this switch is off, but that one is on, then the system works as an XOR loop.
So now we basically built a primitive computer. The dog sensor and the cat sensor are the inputs. They both produce input signals either 0 (animal out) or 1 (animal in). The lamp is the output that produces an output signal of 1 or 0 (on or off). And the state of the switches are also 1s and 0s that define whether today we want to run our loop in AND mode or XOR mode or any other mode. That’s defined by the combination of the switches that are on. The output lamp can be an input signal for a next lamp that takes this lamp and the presence of the owner as two inputs, also hardwired in a way using switches.
Now, these basic operators are actually hardwired in a computer too. So when the 0s and 1s come to the processor (or one little elemental unit of the processor), they come in certain well defined order. Some 0s and 1s represent the switches so that one element in the processor becomes an AND state or OR state or XOR state or NOR state etc. The rest of the numbers represent the input signals. Then this element either shines up and becomes a 1 or stays 0, based on the inputs *and* the switches.
And this happens terribly fast and there are millions of basic units do this in parallel.
So when it comes to the program, everything in the program breaks down to such series of 0s and 1s, some tell how to handle the rest some are the actual stuff to handle.
Latest Answers