isClose

fnbool isClose(T, U, V = CommonType!(FloatingPointBaseType!T, FloatingPointBaseType!U))(T lhs, U rhs, V maxRelDiff = CommonDefaultFor!(T, U), V maxAbsDiff = 0.0)

Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.

Parameters

lhsFirst item to compare.
rhsSecond item to compare.
maxRelDiffMaximum allowable relative difference. Setting to 0.0 disables this check. Default depends on the type of lhs and rhs: It is approximately half the number of decimal digits of precision of the smaller type.
maxAbsDiffMaximum absolute difference. This is mainly usefull for comparing values to zero. Setting to 0.0 disables this check. Defaults to 0.0.

Returns

true if the two items are approximately equal under either criterium.

It is sufficient, when value satisfies one of the two criteria.

If one item is a range, and the other is a single value, then the result is the logical and-ing of calling isClose on each element of the ranged item against the single item. If both items are ranges, then isClose returns true if and only if the ranges have the same number of elements and if isClose evaluates to true for each pair of elements.

See Also

Use feqrel to get the number of equal bits in the mantissa.