3

Seems like R coerces big numbers and cannot compare them effectively:

x = 123412415124231251233213
x == 123412415124231251233214
[1] TRUE
x == 123412415124231251233217
[1] TRUE

Any idea why (maybe a C limitation) and how can that be fixed ?

And look what happens if I convert to character:

x <- as.character(123412415124231251233213)
x
[1] "123412415124231247898884"
criticalth
  • 398
  • 2
  • 9
  • 16
  • One way to fix is x <- "123412415124231251233213" – Agaz Wani Mar 26 '18 at 09:13
  • https://discuss.analyticsvidhya.com/t/handling-of-large-numbers-in-r/53197 – Andre Elrico Mar 26 '18 at 09:14
  • 1
    some other links which might be helpful https://stackoverflow.com/questions/22466328/how-to-work-with-large-numbers-in-r , https://stackoverflow.com/questions/32368555/exactly-storing-large-integers , https://stackoverflow.com/questions/32339636/long-numbers-as-a-character-string – Ronak Shah Mar 26 '18 at 09:16
  • 1
    Also try [This recent question](https://stackoverflow.com/q/49450755/4752675) – G5W Mar 26 '18 at 12:17
  • @AaghazHussain that is not a good solution I will update the issue with some more code the illustrate my point – criticalth Mar 26 '18 at 12:19

0 Answers0