mcs*_*sim 4 r string-formatting
我试图将大数转换为 R 中的十六进制表示形式,但它失败了,因为它无法容纳 32 位整数。有什么办法可以克服这个限制吗?
> 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
Run Code Online (Sandbox Code Playgroud)
幸运的是我找到了解决方案,但需要库 gmp
library(gmp)
> as.character(as.bigz(0xffffffff+0x10000000),b=16)
[1] "10fffffff"
Run Code Online (Sandbox Code Playgroud)