i don’t understand how calculators work. How can something so small solve such complicated formulas in a minute

In: 0

Mathematics can often be broken down into a bunch of simple rules. If you followed these rules slowly and methodically, you could solve all of the same problems that a calculator can. Simple things you probably haven’t thought about in decades, like how you add the smallest digit and carry a 1.

Calculators are given these rules and follow each simple little step, one by one. Because electricity is very fast, they can do each step in a millionth or billionth of a second.

So by the time you notice any time has passed, the calculator has finished doing its thing.

Repost with modifications from when I explained this before.

Basic binary logic gates. The first three operate on two electrical inputs.

* AND: If both are 1, the result is 1. If either one or both are 0, the result is 0.

* OR: If one or the other or both are 1, the result is 1.

* XOR (exclusive OR): If one or the other (but not both) are 1, then the result is 1.

* NOT: Operates on one bit, if it’s 1 the result is 0, if it’s 0 the result is 1.

For example, an AND gate is an electronic circuit that accepts two voltage inputs and has one voltage output. It has just a few electronic components (resistors and wires and stuff, you could easily make one yourself) arranged so that if both inputs are high voltage, the output is high voltage. If one or both of the inputs is low voltage, the output is low voltage. We then interpret high voltage as 1, low voltage as 0, and we can do an AND on two bits. The same works for the next two, just the electronic components are arranged a bit differently to achieve the other results. The NOT gate just inverts the one input, low to high, high to low voltage.

We can use these to do things. Let’s start building.

A half-adder gives you the sum of the two inputs plus the carry. So 1 + 1 = 0 with a 1 carry (like 5+5 is 0 with 1 carry to be 10). You make this half-adder by hooking an AND gate and an XOR gate together, that’s it. You apply high voltage to both inputs (1+1), you get high low voltage out on the add line (0) plus high voltage out on the carry line (1).

But that’s too basic. We need to add numbers we can use, notice we didn’t do anything with that carry. So let’s make a full adder which accepts the numbers to be added and can take that carry from a previous adder. This is made by combining two half-adders with another XOR gate.

Now this is still for one bit, but now we have something we can chain together since each adder accepts the carry from the previous. If you have 8 bits, you string 8 full adders together so each can get the other’s carry (carry out wire connected to the carry in wire on the next one) and output the result. Put in two 8-bit numbers (remember, this is just voltage sent to wires), and you’ll get the 8-bit result plus a carry, if any. We can now add any two numbers 0-255, and we’ll be told if we need to carry a 1.

So now we can add. Subtraction, multiplication, and division all work the same way, just a different number of those basic logic gates arranged differently.

And now we can do any math by controlling what voltages get sent where. You could do this at home with a circuit board, some transistors and resistors. Put two rows of 8 flip switches to describe the first and second input numbers (up = high voltage = 1, down = low voltage = 0) where each switch feeds high or low voltage into one of your 8 full adders. Now hook a set of lights to the output of each full adder plus another light connected to the carry output. As you flip the switches, the lights will change to represent your two added numbers.

Ta-da, you just made a basic binary adding calculator. Now instead of just adders, you could put in the components for a subtractor, a multiplier, and a divider (above), and have another switch that controls which of those is hooked up to the input switches and output lights. Now you’ve made a full-blown binary calculator.

So take these few basic concepts and expand the number and complexity of these components dramatically, and you have how your calculator works.

As far as answers that may take multiple steps, your calculator is doing at least a few million steps per second, so results will seem instant to you.

All dependant on the algorithm implemented, but simple functions like add, subtract, multiply, divide, etc are all super easy to implement with logic gates. Then repepating these functions gives you your equation.

Which aspect of a calculator are looking for help with? The individual operations, the algorithm used to compute multiple operations, or something else?