Sloppy_Math module

is_approximately_zero

procedure · 1 overloadSource

True when abs(f) is at most epsilon, which is 0.0001 unless given. The bound is inclusive, and a NaN is never approximately zero.

The default is an absolute tolerance chosen for values near 1; it is far too large for values measured in micro-units and too small for large ones.

ExampleOpen in playground ↗
assert(is_approximately_zero(0.00005));
assert(is_approximately_zero(-0.00005));
assert(!is_approximately_zero(0.01));
assert(is_approximately_zero(0.01, 0.1));
is_approximately_zero :: (f: float, epsilon := DEFAULT_EPSILON) -> bool

Parameters

f: float
epsilon := DEFAULT_EPSILON

Returns

bool

See also