Skip to content

Setting NA from C code

2 messages · Duncan Murdoch, Brian Ripley

#
In the maps library, NA's are inserted between polygons so lines() can
be used to draw all polygons at once.  The code to do it is like this:

            *x++ = NA_REAL;
            *y++ = NA_REAL;

where x and y are declared as 

	double *x, *y, *range;

and are the arguments passed in through a .C call.

However, the values show up in R as -6.62314033633867e-229 instead of
NA, so the drawing gets messed up.

Any suggestions as to what might be going wrong?

This is happening in Windows, using gcc 2.95.2, R source 1.3.1,
platform i386-pc-mingw32.

Duncan Murdoch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 5 Nov 2001, Duncan Murdoch wrote:

            
You are probably not importing R_NaReal, which is what NA_REAL is a macro
reference to.  That's the point of globalvars.h, which the standard
Makefile forces to be included.

This will not be needed from 1.4.0 on.