equalish | R Documentation |
Check for equality within a tolerance level
equalish(x, y, tolerance = .Machine$double.eps^0.5)
equalish_frac(x, y, tolerance = .Machine$double.eps^0.5)
x, y |
|
tolerance |
|
equalish()
returns TRUE if the absolute difference between x
and
y
is less than tolerance
.
equalish_frac()
returns TRUE
if the relative difference between
x
and y
is smaller than tolerance
. The relative difference is
defined as abs(x - y) / pmax(abs(x), abs(y))
. If both x
and y
are
0
the relative difference is not defined, but this function will still
return TRUE
.
.Machine
a <- 0.7
b <- 0.2
a - b == 0.5
equalish(a - b, 0.5)
equalish_frac(1000, 1010, tolerance = 0.01)
equalish_frac(1000, 1010, tolerance = 0.009)
equalish_frac(0, 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.