This is the third episode of the Binary Numbers And Computers series. In Episode I, we introduced binary numbers, which are used by Computers. In Episode II, we explained why humans use decimal numbers.
In this episode, we are going to dig a little deeper to see why binary numbers are so important to computers.
“Do you know why computers were invented in the first place?” I asked my son.
“Modern computers were invented in World War II. They were created to perform mathematical calculations much faster than humans. For example, the US created a computer to calculate missile trajectories. The Britishes, led by Alan Turing, created a computer to crack encrypted codes by the Germans.”
“So how do computers perform calculations?”
“Right, that’s what we are going to talk about today.”
Computers use binary numbers because electronics have two states: on and off. It turns out, basic binary calculations can be achieved by the way the electric circuits are wired.
Let’s start by a mathematical operation called AND. It’s also a logical operation. These are the results when performing the AND operation on two single digit binary numbers (a, b).
|a||b||a AND b|
Very importantly, when a and b are single digit binary numbers, the result of a AND b is exactly the result of a * b. (a multiplied by b). So how is the AND operation performed in an electric circuit?
This is called a series circuit. In the picture, we have a battery, two switches and a light bulb.
Now you can see that the series circuit completes exactly the AND operation! Only when both inputs are 1 (a.k.a. Both switches are on), the output is 1 (a.k.a. The light is on). In all other cases, the output is 0 – the light is off. Since a and b are single digit binary numbers, the result of a AND b is exactly the result of a * b. (a multiplied by b). Of course, multiplication of multi-digit binary numbers is more complicated, but you can see how series circuits form the basis for multiplication operations.
Another common binary/logical operation is called OR. Here are the results for single digit binary numbers performing the OR operation.
|a||b||a OR b|
The electric circuit to perform this operation is called a parallel circuit.
In this picture, if any of the switches (inputs) is 1, the light is on.
Can the addition of two single-digit binary numbers be performed with the OR operation? Not really. When a=1 b=1, without considering the carry digit, a + b = 0. That’s different from the OR operation. To perform an addition (without considering the carry digit), we need to use the XOR operation.
|a||b||a XOR b|
How is XOR done in an electric circuit?
This needs a little explanation:
Now we have shown you electric circuits can be wired differently to perform simple binary operations. This is the basis for how computers work! To perform more complex operations, you just need more circuits! The whole idea of computer chips is basically to make the circuits so small, that we can fit more and more circuits into smaller and smaller chips! The unit in modern chips is called a transistor. Nowadays, a small chip can contain 10 billion transistors.
Designing computer hardware is part of a engineering branch called Electrical Engineering. You can imagine how important the subject is as our lives are so dependent on computers, cell phones, robots etc. etc. ..