A solution to calculation of odd roots of negative numbers with Calc
rb.henschel at t-online.de
Mon Jul 16 12:00:10 PDT 2012
marlon orlando barahona alvarez schrieb:
> when we try to calculate the cube root of -27 (using the formula = POWER
> (A1, 1/3) -3 Calc should give us but gives us the message # VALUE!
> I solved the problem by modifying the formula as follows:
> =-POWER (-A1, 1/3) and this modification Calc can give us the correct
If you often need it, you should use a named formula or a macro. You
should discuss that on the users mailing list or in a forum.
> Well I think to include this modification in Cal would take a decision
> block, suppose that the entries are "numbers, index". The terms of the
> decision would be:
> if (num <0 & 1/index% 2 = 1)
> The first one test if num is a negative number, the second one trys if
> index is an odd number, yet if an integer. If true both conditions would be
> used if the proposed amendment and was not used the normal function.
> If this helps please let me know. I hope not look like a fool. If Cal can
> do the calculation differently let me know as it does, thanks for
You find the function as ScInterpreter::ScPow() in
sc\source\core\tool\interpr5.cxx. The exponent comes in as double. So
you first need to detect, whether this double value can be read as unit
fraction. There is a class fraction in tools/inc/tools/fract.hxx with a
constructor using a double. But I have not tested, whether it is suitable.
You need C++ knowledge for the core.
More information about the LibreOffice