将长双读入 R
Reading a long double into R
无法将 long double
从文本文件读取到 R 中吗?我看过 bit64
、gmp
、float
等软件包,但它们似乎都在内部管理大型双打。
注意,我指的不是显示 ("options(digits=22)
") 问题。我想读取像 0.0664104763418435999999638041924043818653444759547710418701171875
这样的数字并对其执行操作。如果我无法通过打印来确认我已将完整数字读入会话,我应该能够加载它并将其保存到文件中而不会丢失精度。可能不可能?
运行 64 位机器上的 Fedora 29。
读入为字符。 read.table
有参数 colClasses
来确保数据被解释成什么类型。然后你可以转换成你想要的任何多精度class。例如 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
无法将 long double
从文本文件读取到 R 中吗?我看过 bit64
、gmp
、float
等软件包,但它们似乎都在内部管理大型双打。
注意,我指的不是显示 ("options(digits=22)
") 问题。我想读取像 0.0664104763418435999999638041924043818653444759547710418701171875
这样的数字并对其执行操作。如果我无法通过打印来确认我已将完整数字读入会话,我应该能够加载它并将其保存到文件中而不会丢失精度。可能不可能?
运行 64 位机器上的 Fedora 29。
读入为字符。 read.table
有参数 colClasses
来确保数据被解释成什么类型。然后你可以转换成你想要的任何多精度class。例如 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