<div dir="ltr">Hello Everyone,<div><br></div><div>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,<b> NA_REAL</b> it gives the value as <b>nan</b> and <b>NA_INTEGER</b> 

gives the value as

 <b>-2147483648, and R_NaN as 0</b>.</div><div><br></div><div>I used the following code(from Rcpp FAQ):</div><div>Rcpp::IntegerVector Missing_I() {<br>  Rcpp::IntegerVector v(1);<br>  v[0] = NA_INTEGER; // NA<br>  return v;<br>}<br>Rcpp::NumericVector Missing_N() {<br>  Rcpp::NumericVector v(4);<br>  v[0] = R_NegInf; // -Inf<br>  v[1] = NA_REAL; // NA<br>  v[2] = R_PosInf; // Inf<br>  v[3] = R_NaN; // nan<br>  return v;<br>}<br></div><div><br></div>When I compile the functions using sourceCpp() I get the output as expected:<div>> sourceCpp("~/R/RcppDeepState/inst/extdata/filesave.cpp")<br>> Missing_I()<br>[1] NA  <br></div><div>> Missing_N()<br>[1] -Inf   NA  Inf  NaN<br></div><div><br></div><div>But when I compile the code using the TestHarness it gives me the following output:</div><div>missing_n values: -inf nan inf 0  <br></div><div>missing_i values: -2147483648<br></div><div><br></div><div>I saved the above functions(Missing_I, Missing_N) in a header file and made a call to those functions from the testharness:  <br></div><div><br></div><div>TEST(deepstate_test,datatype){<br>RInside();<br>Rcpp::IntegerVector missing_i = Missing_I();<br>std::cout <<"missing_i values: "<< missing_i << std::endl;<br>Rcpp::NumericVector missing_n = Missing_N();<br>std::cout <<"missing_n values: "<< missing_n << std::endl;<br>}<br></div><div><br></div><div>How can I get the results as expected? Any help is appreciated.</div><div><br></div><div>Thanks,</div><div>Akhila</div><div><br></div><div><br></div><div><br></div></div>