Unary minus precedence preference
|
07-24-2014, 01:35 PM
Post: #25
|
|||
|
|||
RE: Unary minus precedence preference
(07-24-2014 07:31 AM)Wes Loewer Wrote:(07-23-2014 08:27 PM)Wes Loewer Wrote: Well, except for that pesky Excel again. It evaluates 2^3^2 to be 64 instead of 512. It's sad that developers are so careless. Here's a quote from the XLS format specification: Quote:With the exception of control tokens (section 2.2.2.3), display tokens (section 2.2.2.4), and mem So it's clear that Excel uses RPN to store and evaluate expressions. This means that OpenOffice, Gnumeric, etc. could choose the other convention without breaking compatibility with existing spreadsheets (since existing expressions are pre-compiled to RPN, there's no ambiguity!!). They could simply open an old spreadsheet written with Excel and the same formula would display (-2)^2 under the "correct" convention, but will always give the same result of 4. When the user types -2^2 on a new formula, give -4. When you go back to Excel and open that file, Excel will display -(2^2) (under the "wrong" convention) and keep giving the -4 result you got before. Nothing really breaks, so I don't understand their reasoning. Same thing for the associativity of exponents. Claudio |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)