Skip to content
Back to formatted view

Raw Message

Message-ID: <x2r9amy43r.fsf@blueberry.kubism.ku.dk>
Date: 2000-05-28T17:30:32Z
From: Peter Dalgaard
Subject: NA in C/C++
In-Reply-To: Prof Brian D Ripley's message of "Sun, 28 May 2000 16:43:46 +0100 (GMT Daylight Time)"

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