0

I am assigning a large odd number to a variable (1126605209290117121) and it is being shown as (1126605209290117120) [observe the last digit] in the environment. But assigning a large even number is represented correctly. Can someone explain why?

a = 1126605209290117121
print(as.character(a))
[1] "1126605209290117120"

screenshot

kath
  • 7,624
  • 17
  • 32
Ashok Krishna
  • 143
  • 1
  • 5

1 Answers1

0

After searching through the internet I learned that R still has only 32-bit integers. This blog post in R Bloggers summarises the problem clearly

Ashok Krishna
  • 143
  • 1
  • 5
  • It has 64 bit doubles that can represent a larger range of integers, but even this has limits. You might want to consider an arbitrary precision package such as gmp or Rmpfr. – James May 20 '19 at 09:41