# /home/coin/svn-release/Bcps-0.93.11/CoinUtils/src/CoinFloatEqual.hpp File Reference

Function objects for testing equality of real numbers. More...

`#include <algorithm>`
`#include <cmath>`
`#include "CoinFinite.hpp"`
Include dependency graph for CoinFloatEqual.hpp:
This graph shows which files directly or indirectly include this file:

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...

## Detailed Description

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.