G'day Gregory,

On Tue, 26 Oct 2010 19:05:03 -0400
Gregory Ryslik <rsa...@comcast.net> wrote:

> Hi,
> 
> This might be me missing something painfully obvious but why does the
> cube root of the following produce an NaN?
> 
> > (-4)^(1/3)
> [1] NaN

1/3 is not exactly representable as a binary number.  My guess is that
the number that is closest to 1/3 and representable cannot be used as
the exponent for negative numbers, hence the NaN.

Essentially, don't expect finite precision arithmetic to behave like
infinite precision arithmetic, it just doesn't.  The resources
mentioned in FAQ 7.31 can probably shed more light on this issue.

Cheers,

        Berwin

========================== Full address ============================
Berwin A Turlach                      Tel.: +61 (8) 6488 3338 (secr)
School of Maths and Stats (M019)            +61 (8) 6488 3383 (self)
The University of Western Australia   FAX : +61 (8) 6488 1028
35 Stirling Highway                   
Crawley WA 6009                e-mail: ber...@maths.uwa.edu.au
Australia                        http://www.maths.uwa.edu.au/~berwin

______________________________________________
R-help@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.

Reply via email to