#include #include namespace myx { namespace math { bool almost_equal_relative( const float a, const float b, const float maxRelDiff ) { float diff = fabsf( a - b ); float aN = fabsf( a ); float bN = fabsf( b ); float largest = ( bN > aN ) ? bN : aN; if ( diff <= largest * maxRelDiff ) { return( true ); } return( false ); } bool almost_equal_relative( const double a, const double b, const double maxRelDiff ) { double diff = fabs( a - b ); double aN = fabs( a ); double bN = fabs( b ); double largest = ( bN > aN ) ? bN : aN; if ( diff <= largest * maxRelDiff ) { return( true ); } return( false ); } } // namespace math } // namespace myx