# How Does The Computer Work

To be honest I didn’t know the answer to this question until yesterday, taking into account that I work a lot with computers and actually write programs. But anyway this is the truth. I finally figured it out and now can explain to others using simple words. This is what I am going to do in the next paragraphs.

To understand how the computer works first of all we should define a computer. And it is not something complex. Computer has 4 functions that define it as a computer: Input, Storage & Process, Output. So anything that takes an input (numbers, text, voice, data) stores it in memory, processes and returns an output is a computer. Example calculator. It takes numbers, processes them and returns an output being result of addition, subtraction, multiplication or division. It is a computer.

Next we should understand that you can encode any information using binary system – on or off, true or false, 0 or 1. Let’s say we have a bulb. We can encode 2 messages with this bulb – if it’s on – you can pass, if off – you have to wait. With 2 bulbs we can encode 4 messages, with 4 – 16 and so on. But computers works with electric wires and circuits in which all the information is stored and processed. Using electricity you can represent any information. One electric wire with electricity flowing through it can be on or off, true or false, 0 or 1. So with this one piece you can store only two options: yes or no. This is the smallest piece of information that can store a computer and it is called bit. And as in the example with bulb – the more wires we have the more complex information we can store. I guess you understand that today’s computers don’t usually have only one wire :D.

So OK. We understood that you can encode literally anything using binary system. But how does the computer know what to do with this information, how does he understand that here he has to perform addition and here multiplication (or any other type of operation). This is the part I couldn’t understand for a long time. I thought: “OK, we encoded all the information, everything is a number, number is a number, letter is a number, sound is number, image is a number so what’s next??”. And the next thing we have to talk about are circuits.

Circuits are the units that based on input perform always the same operation and produce an output. A simple circuit takes an electric signal and flips it. So if the signal you give it is a 1, the circuit returns you a 0 and vise versa. The more complex circuit can take multiple inputs and combine them. If we have two wires and at least on of them signals 0, the circuit will return 0. It will return 1 only if the first AND the second are 1. This circuit is called AND. And there are many logical circuits like this: OR, NOT, XOR, NAND and so on. By connecting these circuits together, we can make more complex circuits that perform more complex calculations. Another example with ADDER. This is a simple circuit that adds two bits: 0 + 0 = 00 (zero + zero = zero) , 0 + 1 = 01 (zero + one = one), 1 + 1 = 10 (one + one = two). So it takes input signal, processes it and returns an output, performing always the same operation. If we put such circuits together we can perform more complex operations. At the end of the day, everything in the computer is a combination of billions of simple operations, which a human can perform in less than a second. But the computer has few advantages: it does it even faster and it never gets bored.

Actually this is the essence you need to know to understand how the computer works. Yes, later goes CPU, Memory, Input and Output devices, hardware, software, operating system and so on. But knowing the logic behind the binary system and circuits that perform super simple operations already gives you an understanding how the computer works.

For those who wants more or didn’t understand anything written here I will recommend to watch a series of videos with total duration near 30 minutes where Bill Gates and team explain in details and very clearly How Computers Work. Actually thanks to those videos I have gotten more understanding about the insides of the computers.

And the post looks better with some picture, so here is a little tip :D. 