On 29/03/16 09:38, lorieul wrote:
Hello to all,
I have found a fancy behavior of Calc but I cannot decide whether it is
a bug or a "feature". Hence I was looking for your advice before posting
a bug report (if required).
1. Open LO Calc
2. In A1 enter formula "=1-2^2" and press enter key
The result shown is -3 which is ok since
1-2² = 1-(2²) = 1-4 = -3
3. In A2 enter formula "=-2^2" and press enter key
I would expect this to be treated as -2² = -(2²) = -4
But Calc considers it as (-2)² = +4
Quite obviously, a work around is to define the formula as
"=-(2^2)" which indeed returns -4
I've checked the wiki page dedicated to operators [1] but it does not
give much information on operator precedence.
From my standpoint, both examples show an inconsistent behavior of Calc.
For me, either we should have both 1-2^2 = 1+4 = 5 and -2^2 = +4
Or we should have both 1-2^2 = 1-4 = -3 and -2^2 = -4
However, perhaps some of you have a different view point on the matter ?
In other words, is that a bug or is it perfectly normal ?
It looks as though someone has been following a bad example.
A quick search brings up
https://en.wikipedia.org/wiki/Order_of_operations
which says
"There exist differing conventions concerning the unary operator −
(usually read "minus"). In written or printed mathematics, the
expression −3^2 is interpreted to mean 0 − (3^2) = −9 .... but in ....
Microsoft Office Excel (and other spreadsheet applications) and the
programming language bc, unary operators have a higher priority than
binary operators"
Contrary to, eg, perl.
Ouch! Quite contrary to expectation. Here lie monsters :-)
--
Mike Scott
Harlow, Essex, England
--
To unsubscribe e-mail to: [email protected]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted