Let’s take one classic calculator And the app from the iPhone calculator and we perform on both same operations. If we are dealing with two additions/subtractions in a row, the result of the two devices will be the same. But if we perform for example a sum followed by a multiplication (or division), the two results they will be different. But how is it possible? Let’s see it together in this article.
The classic calculator cannot distinguish operations
Let’s place a classic calculator and an iPhone side by side and perform the same operations on both, one after the other:
30 + 20 / 2
On the two screens we will see two different results appear: 25 on the calculator, 40 on the iPhone.
But how is this possible? And which of the two results is correct?
Formally, the correct result is that of the iPhonebut the calculator he didn’t “miscalculate”, he simply performed a different operation.
The order of operations
One of the first things we learn in school is that mathematical operations have a precise order.
If several operations coexist, such as addition and division in this case, and there are no parentheses, they have the precedence multiplication And division on addition and subtraction. The correct result of the equation 30+20/2 in this case it is therefore 40since the division must be performed first and then the addition, from which 30+10=40.
How come then the calculator gives us as a result 25?
Simply put, classic calculators are not programmed to do multiple operations at the same time, so they perform one by one in order of appearance. In this case, then, the calculator is performing (30+20)/2=25.
The phone app, on the other hand, can do something more.
After we type a sum, before saying the result it waits to see what operation we will do next: if it is another sum, then it gives us the partial result, if instead it is a multiplication it waits to know what we will multiply by and first does the multiplication, then the sum.