Eli5: Computers can calculate based on instructions. But how do you teach computers what does it mean to add something, multiply, divide, or perform any other operation?

910 views

Edit: Most of the answers here are wonderful and spot on.

For those who interpreted it differently due to my incorrect and brief phrasing, by ‘teaching’ I meant how does the computer get to know what it has to do when we want it to perform arithmetic operations (upon seeing the operators)?

And how does it do it? Like how does it ‘add’ stuff the same way humans do and give results which make sense to us mathematically? What exactly is going on inside?

Thanks for all the helpful explanations on programming, switches, circuits, logic gates, and the links!

In: 583

43 Answers

Anonymous 0 Comments

For an actual ELI5, imagine you have a bunch of pebbles, some are white and some are black. Based on the way you order them and how many there are, you can read them to get a number.

Now imagine you can do operations on these rocks, for example, switching the last rock will add or subtract 1, or adding another rock at the end will multiply it by 2.

Now with these operations, you devise a machine that can add two lines of rocks just by combining them and checking each column, carrying the value over. It then spits out a new row of rocks with the value.

This machine has not been taught how to add. It has just been created in a way where all it does is add. It doesn’t know anything else, and when it is activated by giving it 2 rows of rocks, it just adds them together and spits out the sum.

Now imagine creating a machine like this for each operation you are going to do, and then you have the basic operations for a computer.

TLDR: the computer is not taught anything, any more than a car is taught how to drive. These operations are as fundamental to its operation as the silicon and metal they are made out of. They are able to do operations as an emergent capability based on their physical design

You are viewing 1 out of 43 answers, click here to view all answers.