Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print big number in hexadecimal

I'm trying to convert big number to hexadecimal representation in R, but it fails, because it can't fit into 32-bit integer. Is there any way to overcome this limitation?

> print(0xffffffff+0x10000000)
[1] 4563402751
> as.hexmode(0xffffffff+0x10000000)
Error in if (is.double(x) && (x == as.integer(x))) x <- as.integer(x) : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In as.hexmode(4294967295 + 268435456) : NAs introduced by coercion
like image 323
mcsim Avatar asked Oct 26 '25 10:10

mcsim


1 Answers

Luckily I found the solution, but requires library gmp

library(gmp)
> as.character(as.bigz(0xffffffff+0x10000000),b=16)
[1] "10fffffff"
like image 181
mcsim Avatar answered Oct 29 '25 00:10

mcsim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!