Why does excel calculate -5^2 as (-5)^2 = 25,
when 0-5^2 is calculated as 0-(5^2) = -25.
Other calculators (including handheld), mathematic software,
and math books, would give the answer -5^2 = -25.
Not exactly true with respect to calculators. It depends on how you choose
to enter -5 in the calculator. If you enter 5, then CHS (change sign) or
the equivalent, you will indeed get +25 when you square it.
Contrary to those with limited experience, there is no single way to do that
in computer languages. Some computer languages do it the way that Excel
does. It was actually a topic of some debate among computer scientists in
the 1950s. But granted, -(5^2) is more common.
Comparisons with mathematics is inappropriate since the precedence is
implied by superscripting.
It is a valid observation that we might want -5^2 and 0-5^2 to have the same
result. But it is not "wrong" if they are different. It is simply the
difference between the unary negative operative and the subtraction
operation, which happen to use the same symbol (-).
The bottom line is: as with natural languages, each computer language has
its own rules for syntax and semantics. Is Yoda-speak "wrong"?