[Rd] sprintf of big int
Sokol Serguei
@oko| @end|ng |rom |n@@-tou|ou@e@|r
Tue May 12 09:39:37 CEST 2026
Hi,
I wanted to print a big integer value in hexadecimal format with sprintf() but could not (cf. here
after). As R supports integer values upto 2**53-1 (storing them in a double) is it possible to make
sprintf() to work on such big values?
Best,
Serguei.
> sprintf("%x", 2**31-1)
[1] "7fffffff"
> sprintf("%x", 2**31)
Error in sprintf("%x", 2^31) :
invalid format '%x'; use format %f, %e, %g or %a for numeric objects
> sessionInfo()
R version 4.6.0 (2026-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Linux Mint 21.1
Matrix products: default
BLAS/LAPACK: /opt/OpenBLAS/lib/libopenblas_nonthreaded_haswell-r0.3.27.so; LAPACK version 3.12.0
locale:
[1] C
time zone: Europe/Paris
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.6.0
More information about the R-devel
mailing list