In python 3 I can easily represent and use fairly large integers such as 2**128
. However, in R I run into problems at much smaller integer values, with 2^53
being the upper limit (and why that limit?). For example, the following problem can occur.
x11 <- 2^54 - 11
x12 <- 2^54 - 12
print(x11, digits = 22)
# [1] 18014398509481972
print(x12, digits = 22)
# [1] 18014398509481972
x11 == x12
# [1] TRUE
I know that I could scale values or use floating point and then deal with machine error. But I'm wondering if there is a library or some other work around for using integers directly. Note that the L
designation does not solve this problem.
In this case I know versions, and hardware matter so this is R 4.0.5 on macos 11.5.1.