OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

# office-formula message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Infix Operator "^" - here's what applications do

• From: "David A. Wheeler" <dwheeler@dwheeler.com>
• To: office-formula@lists.oasis-open.org
• Date: Sat, 24 Feb 2007 14:46:23 -0500 (EST)

```Tomas Mecir:
> The ^ operator used to be right-associative in KSpread, but then, as a
> follow-up to the earlier discussions, I have changed it to be
> left-associative. Thus, at least some applications are already
> affected by what was discussed earlier.

Right.  I don't want to say "we can't revisit decisions"; sometimes new information compels us to do so. But on the other hand, I think we should NOT change a previous decision unless there is a STRONG COMPELLING REASON to do so.  Otherwise we'll never finish.

I spent some time trying to collect REAL data, which I think will at least give us a hand. Here are the results of tests with real spreadsheets and "^". There are two basic issues:
* Is prefix "-" higher precedence than "^"?
- Higher means that -2^2 = (-2)^2 = 4
- Lower means that -2^2 = -(2^2) = -4
* Is "^" evaluated left-to-right or right-to-left?
- Left means 2^3^4 = (2^3)^4 =4096
- Right means 2^3^4 = 2^(3^4) = 2.42E+024

I retyped these two equations into various spreadsheets (I retyped them, to prevent compensating when converting a file), namely =-2^2 and =2^3^4.  Here are the results, in no particular order:

Excel 2003: higher, left
OOo 2.1: higher, left
wikiCalc version 0.97 of 2006-11-14: higher, left
Lotus 1-2-3, v9.8.0208.1200: lower, left
Quattro Pro 12 (native mode): lower, left
(PalmOS) DocumentToGo SheetToGo: lower, left
Gnumeric 1.6.3: higher, right
KDE KSpread 1.6.1: higher, right [BUT KSpread has switched to left-to-right since then]

I think we NEED to define these two issues, instead of leaving them undefined/requiring parens in all cases, in the exchange format.  Obviously, user interfaces can do something different.

The precedence of "-" is obviously debated, but I think we should choose "higher".  The left-to-rightness is less contested if you weight these equally; in any case, I think we should choose "left".  Both are our current values, so in other words, I'm arguing for the status quo.  I believe we should leave things as they are (higher and left).