Forum Discussion
Excel wrong calculation
Hi,
i would like to suggest you to check a math colculation with Excel:
-5^2+25
by math rules should be equal to 0, but Excel is calculating result as 50.
I doubt there is a (maybe known) problem regarding the order operator precedence in the expression parser.
This was a tricky game in the social... but finding that Excel is calculating wrong... i'm here just asking you.
Regards,
--- Nicola Camon
4 Replies
- warrenf320Copper ContributorI have the same issue.
I typed in the formula "-B7^2 + 123.4" and it was parsed as (-B7)^2 + 123.4 rather than as -(B7^2) + 123.4 Ouch!!!It is documented in Calculation operators and precedence in Excel
Under Operator precedence, you'll see that - (negation) is evaluated before ^ (exponentiation). This is different from common practice in mathematics.
- warrenf320Copper Contributor
Thanks for pointing out MS's approach to expression evaluation. It is a pity that MS choose to not follow mathematical tradition. I have advanced degrees in math and physics and I would not have expected this behavior. I have even written expression parsers. Do common programming languages do the same, or has Excel marched down its own unique path? For example, I use Matlab from Mathworks and it reports -5^2 + 25 as 0, not as 50. Python reports -5**2 + 25 as 0 too.