Is it not possible to read a long double
from a text file into R? I've looked at the packages like bit64
, gmp
, float
and others but they all seem to manage large doubles internally.
Note, I am not referring to a display ("options(digits=22)
") problem.. I would like to read a number like 0.0664104763418435999999638041924043818653444759547710418701171875
and perform operations on it. If I'm unable to confirm I've read the full number into the session by printing it, I should be able to load and save it to a file without loss of precision. Possible not possible?
Running Fedora 29 on a 64 bit machine.
Read in as character. read.table
has the parameter colClasses
to ensure what type the data gets interpreted to. Then you can convert to whatever multiple precision class you want. For example with Rmpfr
:
library(Rmpfr)
x <- "0.0664104763418435999999638041924043818653444759547710418701171875"
mpfr(x)
1 'mpfr' number of precision 216 bits
[1] 0.0664104763418435999999638041924043818653444759547710418701171875
# long double has 80 precision bits
mpfr(x,80)
1 'mpfr' number of precision 80 bits
[1] 0.0664104763418435999999638