Hello Everyone, I am trying to use NA_REAL, NA_INTEGER, and R_NaN in my CPP code(doesn't use R main). When I compile and run my code,* NA_REAL* it gives the value as *nan* and *NA_INTEGER* gives the value as *-2147483648, and R_NaN as 0*.
I used the following code(from Rcpp FAQ): Rcpp::IntegerVector Missing_I() { Rcpp::IntegerVector v(1); v[0] = NA_INTEGER; // NA return v; } Rcpp::NumericVector Missing_N() { Rcpp::NumericVector v(4); v[0] = R_NegInf; // -Inf v[1] = NA_REAL; // NA v[2] = R_PosInf; // Inf v[3] = R_NaN; // nan return v; } When I compile the functions using sourceCpp() I get the output as expected: > sourceCpp("~/R/RcppDeepState/inst/extdata/filesave.cpp") > Missing_I() [1] NA > Missing_N() [1] -Inf NA Inf NaN But when I compile the code using the TestHarness it gives me the following output: missing_n values: -inf nan inf 0 missing_i values: -2147483648 I saved the above functions(Missing_I, Missing_N) in a header file and made a call to those functions from the testharness: TEST(deepstate_test,datatype){ RInside(); Rcpp::IntegerVector missing_i = Missing_I(); std::cout <<"missing_i values: "<< missing_i << std::endl; Rcpp::NumericVector missing_n = Missing_N(); std::cout <<"missing_n values: "<< missing_n << std::endl; } How can I get the results as expected? Any help is appreciated. Thanks, Akhila
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel