2

This question may be independent of the language, but I saw this post using R mentions using square root of epsilon as the small number:

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

Why there's a square root ^0.5? Any help's appreciated.

YJZ
  • 3,934
  • 11
  • 43
  • 67

1 Answers1

2

This is not really an R specific question. However, this post provides some answers to your question. Basically, it is a good rule of thumb to avoid loss of precision.

Anders Ellern Bilgrau
  • 9,928
  • 1
  • 30
  • 37