Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
> x <- 1.00042589212565 > x [1] 1.000426
如果我想打印 的确切值x,我该怎么做?
x
对不起,如果这是一个愚蠢的问题。我尝试用谷歌搜索“R”和“exact”或“round”,但我得到的只是关于如何舍入的文章。
先感谢您!
整个会话期间的全局解决方案
options(digits=16) > x [1] 1.00042589212565
或仅在本地为 x:
sprintf("%.16f", x) [1] "1.0004258921256499"
print(x, digits=15)
或者
format(x, digits=15)
sprintf("%.14f", x)