Check for equality within a tolerance level
equalish.RdCheck for equality within a tolerance level
Usage
equalish(x, y, tolerance = .Machine$double.eps^0.5)
equalish_frac(x, y, tolerance = .Machine$double.eps^0.5)Arguments
- x, y
numericvectors- tolerance
numericscalar. tolerance level (absolute value). Defaults to.Machine$double.eps^0.5which is a sensible default for comparing floating point numbers.
Value
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.