Jerry W. Lewis said:
Interesting and surprising. Thanks for the information.
Purely for the sake of argumentativeness, why surprising? It had to
return -9 or +9, and given the precedence in most programming
languages that provide both unary minus and exponentiation operators
-9 would be more common. Indeed, in VBA -3^2 returns -9.
Conformity with VisiCalc wasn't a good idea. VisiCalc was APL in
reverse - all left to right evaluation. For example, 2*3^4 = (2*3)^4
rather than 2*(3^4), and 2+3*4 = (2+3)*4 rather than 2+(3*4). Just as
in APL, and for the same reason, this is UNAMBIGUOUS.
Counterintuitive, perhaps, but unambiguous. If Excel also enforced
left to right evaluation with no operator precedence and only
parentheses to change evaluation order, then Excel could claim
consistency with VisiCalc, FWLIW. It doesn't, so Microsoft can't claim
conformity with either VisiCalc or 123 to support their choice of
operator precedence. They came up with this all on their own.
That Lotus chose to have 123 behave differently than VisiCalc was a
good thing, IMO. OTOH, Microsoft Excel is aking to COBOL rather than
FORTRAN. How nice!
That said, at least in the context of programming languages, in which
various spreadsheets' formulas are functional languages, there's no
consistent convention for operator precedence. Whether or not this
is/was a mistake is irrelevant to the extent that changing it would be
worse. In any case, this is *not* a bug in Excel, it's a feature
arising from a possibly obtuse design decision.
So far 4 different parsing approaches in spreadsheets and programming
languages have been described: APL's no precedence, strict right to
left; VisiCalc's no precedence, strict left to right; the mainstream's
(123, FORTRAN, BASIC including VBA, Perl, Python, etc.) exponentiation
taking higher precedence than negation; and the fringe's (Excel,
COBOL, apparently AppleScript, REXX and a few others) negation taking
higher precedence than exponentiation.
At the very least, no matter what may be correct in textbooks, there's
ample variety in programming languages, so anyone attempting to use
any programming language to perform calculations on a digital computer
had better check their programming language's operator precedence.
Bitching, whining and moaning about how this is wrong, wrong, terribly
wrong is wasted time, breath and effort.