fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool
[src]
Performs an approximate comparison of two floating point values x
and y
. Returns true if the absolute difference between them is less or equal than max(|x|, |y|) * tolerance
, where tolerance
is a positive number greater than zero.
The tolerance
parameter is the relative tolerance used when determining if the two numbers are close enough; a good value for this parameter is usually sqrt(floatEps(T))
, meaning that the two numbers are considered equal if at least half of the digits are equal.
Note that for comparisons of small numbers around zero this function won’t give meaningful results, use approxEqAbs
instead.
NaN values are never considered equal to any value.