On 2013/05/27 11:20 AM, Torokhov Sergey wrote:
There is a some strange behaviour in "OpenOffice Calc" (and in Microsoft Office
too). Did it was made in OpenOIffice for compability with MSO?
This seems to concern all combinations of even degrees and "minus" sign in the
begining of formula
1. Enter in cell the expression: =-1^2
The result will be equal "1" instead of "-1"
Note that "=1-2^2" results in "-3" and it's true but "-2^2" results "4" instead of
"-4"
2. Well, now enter the expression: =-(1)^2
The result will be equal "1" instead of "-1" again
(or expression like "=-(1+2)^2" the result will be "9" instead of "-9")
3. Only if enter the expression: = -(1^2)
The result now will be right and equal "-1"
Such behaviour contradicts mathematical notation of formula.
I'm quite sure AOO's way of interpreting such an expression was
determined by compatibility considerations. For what its worth Wikipedia
[1| also states these different conventions:
"There exist differing conventions concerning the unary operator −
(usually read "minus"). In written or printed mathematics, the
expression −32 is interpreted to mean −(32) = −9,[3] but in some
applications and programming languages, notably the application
Microsoft Office Excel and the programming language bc, unary operators
have a higher priority than binary operators, that is, the unary minus
(negation) has higher precedence than exponentiation, so in those
languages −32 will be interpreted as (−3)2 = 9.[4] In cases where there
is the possibility that the notation might be misinterpreted,
parentheses are usually used to clarify the intended meaning, however
due to the syntax of most major programming languages, it is usually
hard or impossible to be ambiguous."
[1]
http://en.wikipedia.org/wiki/Order_of_operations#Exceptions_to_the_standard
Herbert
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org