[R] NA in C/C++

John Chambers jmc at research.bell-labs.com
Mon May 29 16:46:31 CEST 2000


A few general comments.

The IEEE 754 floating-point standard is one of the more striking
successes in getting computer hardware to be more useful for those who
program.  There are, of course, glitches, both in non-compliance and
in holes in the standard, but if we can work within the standard as
far as possible, while complaining about the glitches, we'll be better
off, and C/C++ software produced will be more likely to port
gracefully to other environments.

>From that view, using C routines that are part of the standard (while
perhaps overriding them on machines that don't conform) has advantages
inside your own C/C++ code, IF that code is not intrinsically R/S
dependent.  So isnan() would be better in that case, R_IsNaNorNA()
better for code that is R-dependent.

Where it makes sense, there is also an advantage to doing the relevant
testing in the S language and passing the result to the C code, either
directly, say as a logical vector argument, or indirectly by doing the
selection outside and leaving the C code to just grind away on the
selected subset of the data.  Within the S language, is.na() is the
best test, because it deals with either floating point or integer
data.

Anyone interested in the relevance of the standard, or just a read
through some insightful if eccentric ranting about numerical
computation generally should eventually encounter W. Kahan, "the
father of IEEE 754".

There is a directory on the web at the Berkeley CS department:
  www.cs.berkeley.edu/%7Ewkahan/ieee754status/
All the papers in that directory are worth looking at, allowing
for Kahan's legendary rages at all those who failed his standards.
Having had the privilege (well, looking back on it anyway) of taking a
course from Kahan, I can verify that his personality comes across well
in the papers.

-- 
John M. Chambers                  jmc at bell-labs.com
Bell Labs, Lucent Technologies    office: (908)582-2681
700 Mountain Avenue, Room 2C-282  fax:    (908)582-3340
Murray Hill, NJ  07974            web: http://www.cs.bell-labs.com/~jmc
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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