Bug 74525 - Other: Calculates wrong value of expression starting with minus sign
Summary: Other: Calculates wrong value of expression starting with minus sign
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.2.0.4 release
Hardware: Other Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
: 106921 142451 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-02-04 18:21 UTC by surendra_beniwal
Modified: 2021-05-24 07:51 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
A spreadsheet Which shows the expected and wrong behaviour while evaluating the expressions. (43.78 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-02-04 18:21 UTC, surendra_beniwal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description surendra_beniwal 2014-02-04 18:21:32 UTC
Created attachment 93398 [details]
A spreadsheet Which shows the expected and wrong behaviour while evaluating the expressions.

Problem description: 
Whenever I put "=-(5)^2" in any cell (without quotes) and put enter, it calculates the value as 25, which should be -25 instead. It appears that it takes square of -5 instead of 5. If you try =-(5)^3 then it calculates -125, which is trivially correct. 

The problem encountered when I was generating a column of y values for given x range, for y = 10*exp(-(x-11)^2/100)

Steps to reproduce:
1. .... Open Libreoffice Calc
2. ....Put "=-(5)^2" in any cell (without quotes) and press enter.
3. ....You should expect a value -25, but it shows 25 instead.

Current behavior:   -(5)^2 >>> 25

Expected behavior:   -(5)^2 >>> -25

              
Operating System: Ubuntu
Version: 4.2.0.4 release
Comment 1 Dominique Boutry 2014-02-05 10:59:37 UTC
Hi.

The precedence of Excel operators is given in ""http://office.microsoft.com/en-us/excel-help/calculation-operators-and-precedence-HP010342223.aspx". Same for LibreOffice CALC. See "http://lpsolit.wordpress.com/2011/05/17/excel-openoffice-libreoffice-or-when-developers-think-rules-do-not-apply-to-them/".

OK, questionnable (and questionned!) for -4*2. But it is too late to change. There are worst precedence tables in the world of data processing (APL...).

Not A Bug.
Comment 2 Timur 2021-05-24 07:51:12 UTC
*** Bug 142451 has been marked as a duplicate of this bug. ***
Comment 3 Timur 2021-05-24 07:51:19 UTC
*** Bug 106921 has been marked as a duplicate of this bug. ***