Skip to content

Conversation

dipterix
Copy link

bit64::as.integer64(2^63) produces different results on different machines (see #19). 2^63 is stored as double in R. When converting double 2^63 to long long, M1 Mac results in 9223372036854775807.

print_bit <- Rcpp::cppFunction(r"(
SEXP print_bit(SEXP obj){
  
  long long tmp1 = *REAL0(obj);
  printf("%lld ", tmp1);
  printf("%f ", (double(tmp1)));

  return(R_NilValue);
}
)")
invisible(print_bit(2^63))

# M1 Mac
> 9223372036854775807 9223372036854775808.000000 

# x86_64 Ubuntu 
> -9223372036854775808 -9223372036854775808.000000

Therefore, I propose this change from if (x[i]<imin || x[i]>imax) to if (x[i]<imin || x[i]>=imax).

(This change will trigger naflag)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant