Bug 43509 - exponent priority in calculation order - wrong result
Summary: exponent priority in calculation order - wrong result
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.4.4 release
Hardware: All All
: high major
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
: 48470 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-12-04 02:42 UTC by nicolabarbini
Modified: 2012-04-10 02:48 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nicolabarbini 2011-12-04 02:42:23 UTC
Problem description: 

the exponent is applied both to the base and to the leading sign 

Steps to reproduce:

write in a cell
=-1^2
should be considered as 
=-(1^2)
NOT as
=(-1)^2

so the current result is 1
instead of -1


Platform (if different from the browser): 
              
Browser: Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:8.0) Gecko/20100101 Firefox/8.0
Comment 1 wope 2012-03-04 10:07:30 UTC
the priority of unary operators is higher then binary operators. From there, the result is correct
Comment 2 vitriol 2012-04-09 09:01:50 UTC
*** Bug 48470 has been marked as a duplicate of this bug. ***
Comment 3 potrykus.gelsenkirchen 2012-04-10 02:26:47 UTC
(In reply to comment #1)
> the priority of unary operators is higher then binary operators. From there,
> the result is correct

(In reply to comment #1)
> the priority of unary operators is higher then binary operators. From there,
> the result is correct

-3^2=-9
because operator ^ has higher precedence than -
 Mathematica, Matlab, Matcad, Derive,Maxima,Scilab,Freemat,Octave,Lotus,VB.NET    
gives -9 too.

For +9, it should be written as: (-3)^2. 

when -3^2=9
then:
  3^2-3^2=0
and
  -3^2+3^2=18  ??

see too

links:
http://www.wolframalpha.com/input/?i=2%5E3%5E2
http://www.wolframalpha.com/input/?i=-3%5E2
Comment 4 nicolabarbini 2012-04-10 02:48:40 UTC
in a general purpose program
a "-" sign should be considered a minus sign, not an unary operator :
at school everyone is taught that ^ has the priority on a sign,
only a few of these learn about existence of unary operators later on.

Most people won't understand or expect that ^ has the priority on *,/ and + but not on -,
it is very insidious.