Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #19 #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix #19 #20

wants to merge 1 commit into from

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