Skip to content

isCloseRelative

isCloseRelative(a, b, relTolerance): boolean

Defined in: packages/core/src/number/is-close-relative.ts:21

Tests whether two numbers are within a relative tolerance of each other: `|a

  • B| <= relTolerance * max(|a|, |b|)`.

Scale-free, and therefore undefined at the origin — the bound collapses to |a| <= relTolerance * |a|, false for every non-zero a. Nothing but 0 is ever relatively close to 0. Use isCloseAbsolute for values that straddle zero, or isCloseTo to combine the two.

No default: a relative tolerance is a claim about how much error the computation that produced a and b may have accumulated, which only the caller knows.

number

The first number to compare.

number

The second number to compare.

number

The relative tolerance.

boolean

true if the numbers are close within the specified relative tolerance, false otherwise.