[R] (-8)^(1/3) == NaN?
jim holtman
jholtman at gmail.com
Sun Jul 19 23:13:11 CEST 2009
If the power that a number is being raised to is integer, then is does
evaluate honoring the unary minus.
> (-2) ^ 5 #integer power
[1] -32
> (-2) ^ 5.1
[1] NaN
>
-8^(1/3)
is parsed as -(8^(1/3)) according to operator precedence.
On Sun, Jul 19, 2009 at 4:49 PM, Liviu Andronic<landronimirc at gmail.com> wrote:
> On Sun, Jul 19, 2009 at 12:28 AM, jim holtman<jholtman at gmail.com> wrote:
>> First of all, read FAQ 7.31 to understand that 1/3 is not
>> representable in floating point. Also a^b is actually exp(log(a) * b)
>> and log(-8) is not valid (NaN).
>>
>
> If this is so, why would the following evaluate as expected?
>> (-8)^(3)
> [1] -512
>
> Liviu
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list