[R] (-8)^(1/3) == NaN?

jim holtman jholtman at gmail.com
Sun Jul 19 19:33:27 CEST 2009


It is the order of operator precedence.  Look at what you typed:

-8^1/3 is parsed as -(8^1)/3 = -2.66666

On Sun, Jul 19, 2009 at 1:12 PM, Victor Manuel Garcia
Guerrero<vmgarcia at colmex.mx> wrote:
> It' true, but if you type -8^(1/3) returns -2, and if you type -8^1/3 it returns -2.66666, maybe there are some rules about parenthesis...
>
> regards
>
> Víctor
>
>
> ________________________________
>
> De: r-help-bounces at r-project.org en nombre de Dave DeBarr
> Enviado el: sáb 18/07/2009 05:04
> Para: r-help at r-project.org
> Asunto: [R] (-8)^(1/3) == NaN?
>
>
>
> Why does the expression "(-8)^(1/3)" return NaN, instead of -2?
>
> This is not answered by http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-powers-of-negative-numbers-wrong_003f
>
> Thanks,
> Dave
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
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