I have a BigInt number.If I try to store it in R
R> a <- 9223372036854775807
R> a
[1] 9.223372e+18
As you can notice its loosing info of last few digits. I tried multiple other ways to solve this but no luck like increasing options(digits = 22) or changing to numeric, double, integer.
> as.integer(9223372036854775807)
[1] NA
Warning message:
NAs introduced by coercion to integer range
R> as.numeric(9223372036854775807)
[1] 9.223372e+18
R> as.double(9223372036854775807)
[1] 9.223372e+18
Can anyone help me with this problem. I want to retain the same original value. I also do not want to install any external package.
We can use as.integer64
from bit64
library(bit64)
as.integer64(as.character(a))
#integer64
#[1] 9223372036854775807
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With