YJZ
YJZ

Reputation: 4214

why use square root of epsilon as the small number

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.

Upvotes: 3

Views: 2634

Answers (1)

Anders Ellern Bilgrau
Anders Ellern Bilgrau

Reputation: 10233

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.

Upvotes: 3

Related Questions