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?

948 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

You don’t.

It’s a split between hardware and emulation. Hardware has no concept of arithmetic. It knows only about registers, memory, and instructions.

An instruction could be: move value A to memory location B; increment register C by D, etc.

We give addition, subtraction, multiplication, and division meaning. For those, we have a specific set of instructions to perform each.

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