小编hyp*_*sis的帖子

R 中大数的准确性

R可以准确表示多少位数字?基于问题的答案在这里,并在这里文档,我希望R键好得多做的比我在下面的迷你例子(精度击穿后16位数字):

log(.Machine$double.xmax, 10)
# 308.2547

for (i in 1:30) {
   a <- rep(1, i)  # make a vector of 1s
   b <- paste(a, collapse = '')  # turn into string
   d <- as.double(b)  # turn into double
   e <- format(d, scientific = FALSE)  # turn into string
   print(e)
}

# "1"
# "11"
# "111"
# "1111"
# "11111"
# "111111"
# "1111111"
# "11111111"
# "111111111"
# "1111111111"
# "11111111111"
# "111111111111"
# …
Run Code Online (Sandbox Code Playgroud)

r

5
推荐指数
0
解决办法
76
查看次数

标签 统计

r ×1