approxEqual

fnbool approxEqual(T, U, V)(T value, U reference, V maxRelDiff = 1e-2, V maxAbsDiff = 1e-5)
deprecated approxEqual will be removed in 2.106.0. Please use isClose instead.

Computes whether a values is approximately equal to a reference value, admitting a maximum relative difference, and a maximum absolute difference.

Warning: This template is considered out-dated. It will be removed from Phobos in 2.106.0. Please use isClose instead. To achieve a similar behaviour to approxEqual(a, b) use isClose(a, b, 1e-2, 1e-5). In case of comparing to 0.0, isClose(a, b, 0.0, eps) should be used, where eps represents the accepted deviation from 0.0."

Parameters

valueValue to compare.
referenceReference value.
maxRelDiffMaximum allowable difference relative to reference. Setting to 0.0 disables this check. Defaults to 1e-2.
maxAbsDiffMaximum absolute difference. This is mainly usefull for comparing values to zero. Setting to 0.0 disables this check. Defaults to 1e-5.

Returns

true if value is approximately equal to reference 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 approxEqual on each element of the ranged item against the single item. If both items are ranges, then approxEqual returns true if and only if the ranges have the same number of elements and if approxEqual evaluates to true for each pair of elements.

See Also

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