Frequently asked questions - Calc
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
When I calculate - x^2
, LibreOffice calculates (-x)^2
. Why?
When you enter a formula of the type:
= - 10^2
the sign -
is not seen as a subtraction symbol, but as the sign that number 10
is negative.
Thus LibreOffice interprets the formula:
= (-10)^2
The result seems false from the mathematical point of view: in terms of the priority of operators, raising to a power should be done before subtraction. LibO seems to do the opposite. The reason is that for LibO, subtraction is a binary operation, which needs two values, one to the left and one to the right. If there is only one value to the right, the minus sign is a unitary operator which then takes priority. To avoid all ambiguïty, it is recommended to use parentheses:
= - (10^2)
or to use the power function:
= - POWER(10;2)
Debates dealing with the opportunity of correcting this bug can be found at i#66735.