I\'m looking for a way to consistently ignore small differences between floating point numbers in R (these are double precision floating points as per IEC 60559), by using b
Warning: this is not an direct answer to the question.
I find the following two functions useful. They allow me to compare doubles to a given degree of precision.
are.equal <- function(x, y, tol = .Machine$double.eps^0.5) abs(x - y) < tol
is.zero <- function(x, tol = .Machine$double.eps^0.5) abs(x) < tol
are.equal(1.45 - 0.55, 2.45 - 1.55)
#[1] TRUE
is.zero(1.45 - 0.55 - (2.45 - 1.55))
#[1] TRUE