After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 115941 - Add parens to make XL style negation precedence unambiguous
Add parens to make XL style negation precedence unambiguous
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: import/export MS Excel (tm)
git master
Other All
: Low enhancement
: ---
Assigned To: Jody Goldberg
Jody Goldberg
: 131486 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2003-06-25 14:53 UTC by Andreas J. Guelzow
Modified: 2008-12-02 20:15 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andreas J. Guelzow 2003-06-25 14:53:12 UTC
While I already know what will happen to this report due to the comments on
irc, I think it is important to record the issue:

in current cvs,  -2^2 evaluates to 4

standard mathematics would have this evaluate to -4 since the precedence of
exponentiation is usually higher than the precedence of negation.

the fact that XL makes the same error should not be a justification.

I guess this may be a reason why we should never use a spreadsheet in a
university classroom.
Comment 1 Morten Welinder 2003-06-25 18:48:42 UTC
I have a patch that at makes the pretty printer print either
-(2^2) or (-2)^2, but never -2^2.

That takes some of the surprise out and as files gets saved, the
expression in there will immune to future parsing changes.
Comment 2 Andreas J. Guelzow 2003-06-25 19:11:50 UTC
I guess that means that -2^2 would be reformated to (-2)^2. That is
something I can live with.
Comment 3 Morten Welinder 2003-06-26 01:37:50 UTC
That fix is in, but jody had something over in XL that needed doing
there.
Comment 4 Andreas J. Guelzow 2004-01-14 23:22:58 UTC
*** Bug 131486 has been marked as a duplicate of this bug. ***
Comment 5 Morten Welinder 2004-01-15 16:01:33 UTC
Note, that there are actually two different issues with -2^2:

A. How should we parse those four characters?
   A1.  -(2^2)
   A2.  (-2)^2              [a negative constant -2]
   A3.   (-(2))^2           [unary minus applied to constant 2]

   The difference between A2 and A3 does not affect the result.

B. Given the Excel-introduced confusion, how should we pretty-print
   the various possibilities?

We have solved B by introducing an extra parentheses so we clearly
distinguish A1 from A2/A3.

A is not really solvable.  Different people desire different things.
It is clearly the dominant math feeling that A1 is right.  (Those
same people do not recognize A2.  Yet they will still claim that -2
is a member of Z, even though Z contains numbers, not unary
expressions.  These are awfully sloppy people.)
Comment 6 Morten Welinder 2008-12-02 20:15:27 UTC
The parser now introduces explicit ()s in this case.  There no longer is a
need to change the XL side.

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.