Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Header <boost/test/tools/floating_point_comparison.hpp>

algorithms for comparing floating point values

namespace boost {
  namespace math {
    namespace fpc {
      template<typename T, bool enabled> struct tolerance_based_delegate;

      template<typename T> struct tolerance_based_delegate<T, false>;
      template<typename T> struct tolerance_based_delegate<T, true>;

      template<typename T> struct tolerance_based;
      template<typename FPT> struct percent_tolerance_t;

      template<typename FPT> class close_at_tolerance;
      template<typename FPT> class small_with_tolerance;

      // Method for comparing floating point numbers. 
      enum strength { FPC_STRONG, FPC_WEAK };
      template<typename FPT> 
        std::ostream & 
        operator<<(std::ostream & out, percent_tolerance_t< FPT > t);
      template<typename FPT> 
        percent_tolerance_t< FPT > percent_tolerance(FPT v);
      template<typename FPT> bool is_small(FPT fpv, FPT tolerance);