Saturday, April 23, 2011

Calculator Bug?

What is the correct answer for 30 / 2 (2+3) / 5? 0.6 or 15?

Manual mathematical calculation it is 15!
 30 / 2 (2+3) / 5 = 30 / 2 (5) / 5 = 15 (5) /5 = 75 / 5 = 15.

Then why is it some calculators come up with the wrong answer?



The answer is simple, this is because of some programing bug, multiplication has a higher priority function then division.  So the calculator will see 30/2*5/5 after computing (2+3) and compute the multiplication 1st , followed by the division so the equation would become 30 / 10 / 5 = 3/5 = 0.6.

Many software has already resolve this issue. Attempting to enter "=30/2(2+3)/5" in Excel will result in the following warning.

Accepting the change will give the correct answer, as  multiplication *, division /, and modulus %, now has the same priority.

Similarly the Calculator program in Windows.


The '2' cannot be entered without first pressing the arithmetic operator.

No comments:

Post a Comment