Computes whether a values is approximately equal to a reference value, admitting a maximum relative difference, and a maximum absolute difference.
bool approxEqual(T, U, V) (
V maxRelDiff = 0.01,
V maxAbsDiff = 1e-05
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
represents the accepted deviation from 0.0."
|value||Value to compare.|
|maxRelDiff|| Maximum allowable difference relative to |
|maxAbsDiff|| Maximum absolute difference. This is mainly usefull
for comparing values to zero. Setting to 0.0 disables this check.
Defaults to |
value is approximately equal to
either criterium. It is sufficient, when
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
each element of the ranged item against the single item. If
both items are ranges, then
and only if the ranges have the same number of elements and if
approxEqual evaluates to
true for each pair of elements.
feqrel to get the number of equal bits in the mantissa.
Walter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger