为什么使用 epsilon 的平方根作为小数

why use square root of epsilon as the small number

这个问题可能与语言无关,但我看到 this post using R 提到使用 epsilon 的平方根作为小数:

is.wholenumber <-
    function(x, tol = .Machine$double.eps^0.5)  abs(x - round(x)) < tol

为什么有平方根 ​​^0.5?任何帮助表示赞赏。

这不是真正的 R 特定问题。但是,this post 为您的问题提供了一些答案。基本上,避免精度损失是一个很好的经验法则。