Dip
0.92.4
|
Function objects for testing equality of real numbers. More...
Go to the source code of this file.
Classes | |
class | CoinAbsFltEq |
Equality to an absolute tolerance. More... | |
class | CoinRelFltEq |
Equality to a scaled tolerance. More... | |
Function objects for testing equality of real numbers.
Two objects are provided; one tests for equality to an absolute tolerance, one to a scaled tolerance. The tests will handle IEEE floating point, but note that infinity == infinity. Mathematicians are rolling in their graves, but this matches the behaviour for the common practice of using DBL_MAX
(numeric_limits<double>::max()
, or similar large finite number) as infinity.
Example usage:
double d1 = 3.14159 ; double d2 = d1 ; double d3 = d1+.0001 ; CoinAbsFltEq eq1 ; CoinAbsFltEq eq2(.001) ; assert( eq1(d1,d2) ) ; assert( !eq1(d1,d3) ) ; assert( eq2(d1,d3) ) ;
CoinRelFltEq follows the same pattern.
Definition in file CoinFloatEqual.hpp.