matrix() can't handle NaN (PR#193)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
12 May 1999 15:13:15 +0200


ripley@stats.ox.ac.uk writes:

> > Splus> is.nan(as.double("NaN"))
> > [1] T
> 
> and so does my R on Solaris. On Linux
> 
> > is.nan(as.double("NaN"))
> Warning: NAs introduced by coercion
> [1] FALSE
> 
> so I think there is a problem with Linux versions specifically. The
> conversion is done by strtod. Solaris says (same man page)
> 
>      If str is NaN, then atof() returns NaN.
> 
> This sort of mess is my underlying objection: should we be assuming
> IEEE arithmetic, let alone a particular implementation of it?

Aha! I wonder if that is a Solaris specialty or actually conforming to
standards? A little digging on deja.com turned up a couple of blanket
statements to the effect that "any implementation where strtod can
return NaN is broken", but I'm not too sure about their authority.
Even the textual representation "NaN" is IEEE-854, not 754....

Whatever. I think we should fix as.double() (really: as.vector(x,
"double")) to accept the IEEE extended values in the same way that the
language itself does. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._