[R] NA in C/C++

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Sun May 28 19:30:32 CEST 2000


Prof Brian D Ripley <ripley at stats.ox.ac.uk> writes:

> > Although I know that IEEE floating point arithmetics supports NaN and
> > Inf, I cannot find
> > any information about this (e.g. in any of my many C++ books)
...
> It's in Writing R Extensions (sections 3.7.3 and 4.4 in the copy I have to
> hand, but it's in the concept index). You cannot assume in R that NA is
> represented by an NaN, although on most machines it is.  Conversely, most
> NaNs are not NA.

Perhaps it is necessary to be a little more specific here: The IEEE
NaN is not a single value, but a set of values characterized by having
an all-ones exponent and a non-zero significand (the cases with a zero
significand are +Inf and -Inf). Have a look at

http://www.linuxsupportline.com/~billm/index.html

for the details.

The double NA in R on IEEE-supporting systems is the NaN with
significand 1954 (no, I don't know who was born that year...). 

However integers have no definition of NaN, so NaInt is INT_MIN and
for systems that don't support IEEE, we have some special hacks too.
Have a look in src/include/R_ext/Arith.h and src/main/arithmetic.c. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list