File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
inst/include/Rcpp/sugar/tools Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 2525namespace Rcpp {
2626namespace sugar {
2727
28+ static unsigned long const R_UNSIGNED_LONG_NA_REAL = *(unsigned long *)(&NA_REAL);
29+ static unsigned long const R_UNSIGNED_LONG_NAN_REAL = *(unsigned long *)(&R_NaN);
30+
31+ inline bool Rcpp_IsNA (double x) {
32+ return *reinterpret_cast <unsigned long *>(&x) == R_UNSIGNED_LONG_NA_REAL;
33+ }
34+
35+ inline bool Rcpp_IsNaN (double x) {
36+ return *reinterpret_cast <unsigned long *>(&x) == R_UNSIGNED_LONG_NAN_REAL;
37+ }
38+
2839inline int StrCmp (SEXP x, SEXP y) {
2940 if (x == NA_STRING) return (y == NA_STRING ? 0 : 1 );
3041 if (y == NA_STRING) return -1 ;
@@ -57,7 +68,7 @@ struct MapCompare<double> {
5768
5869 // this branch inspired by data.table: see
5970 // https://github.com/arunsrinivasan/datatable/commit/1a3e476d3f746e18261662f484d2afa84ac7a146#commitcomment-4885242
60- if (R_IsNaN (right) and R_IsNA (left)) return true ;
71+ if (Rcpp_IsNaN (right) and Rcpp_IsNA (left)) return true ;
6172
6273 if (leftNaN != rightNaN) {
6374 return leftNaN < rightNaN;
You can’t perform that action at this time.
0 commit comments