https://bz.apache.org/bugzilla/show_bug.cgi?id=62121

--- Comment #3 from Axel Howind <[email protected]> ---
I just tried that in Excel 2010 which will give an error for "-2^(1/2)" and
calculate "-3^(1/2)". So Excel at least does what is to be expected in this
case.

If we pull out the sign, the result will be wrong for -2^(1/2), so that change
should rather not be made.

> The solution to this problem is to alter the calculation that happens. 
> We can alter the calculation is "-1 * (2 ^ 0.333..)" which is functionally
> the same but is supported by Math.pow(). 

No, it is not the same. You make the assumption that "0.333.." is the same as
"1/3", which would be true if we had exact mathematic functions. But we don't
have these, and no matter to which precision we can approximate 1/3, we still
have to use an approximation, and the exact result of -2^(x) will be imaginary
for an infinite number of values in the interval between the approximation we
chose and -1/3.

I don't know if my above explanation is understandable. In short, -2^(1/n) is
imaginary for even values of n and negative for odd values of n. That function
is not continuous, and you'd better not rely on getting correct results.

If for any reason you believe that you have a case where it is safe to pull the
minus out and calculate as you suggested, just use a pair of parenthesis.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to