exupero's blog

Four-function calculator behavior

Last year I wrote a post about generating a sequence of calculator operations whose result spells a word when the calculator is turned upside-down. I've turned that algorithm into an interactive web page, and in the process I discovered a difference in how the iPhone's calculator behaves compared to simpler four-function calculators.

On a basic four-function calculator, pressing one of the plus, minus, multiply, or divide keys implicitly applies the previous, completed operation. For example, pressing


produces 20 (that is, (2 + 3) × 4). You can see this when you push the × key and the display immediately shows 5 (2 + 3), as if the equals key had been pressed. Such calculators don't have operator precedence; all operations are left associative.

This is what I expect from a four-function calculator, so I was surprised when the basic iPhone calculator behaved differently. If I press the same sequence of keys shown above, the iPhone shows 14 (that is, 2 + (3 × 4)), implicitly calculating chains of operations by mathematical precedence. To get 20, I have to press the equals key before multiplying to force the intermediate 5 to show on the display:


(I mention the iPhone specifically because that's what I have to test on. If other smartphone calculators behave similarly, email me.)

I wonder how this difference in behavior impacts Internet arguments about the correct answer for expressions like 2 + 3 × 4. I've assumed that the difference between people who believe the answer is 14 and people who believe it's 20 is the difference between people who learned to do math and people who learned to do math on a calculator, but if some basic-looking calculators don't perform intermediate calculations unless the equals key is pressed, then there may also be differences between what kind of calculator people are using and whether a user habitually forces intermediate calculations by pressing the equals key.