os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/math_aux.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/math_aux.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,21 @@
     1.4 +#ifndef __MATH_AUX_H
     1.5 +#define __MATH_AUX_H
     1.6 +
     1.7 +#include <limits>
     1.8 +
     1.9 +/*
    1.10 + * This function is not only used to compare floating point values with a tolerance,
    1.11 + * it also leads to ambiguity problems if the called functions do not have the
    1.12 + * right prototype.
    1.13 + */
    1.14 +template <class _Tp>
    1.15 +bool are_equals(_Tp val, _Tp ref) {
    1.16 +  if (val < ref) {
    1.17 +    return (ref - val) <= std::numeric_limits<_Tp>::epsilon();
    1.18 +  }
    1.19 +  else {
    1.20 +    return (val - ref) <= std::numeric_limits<_Tp>::epsilon();
    1.21 +  }
    1.22 +}
    1.23 +
    1.24 +#endif // __MATH_AUX_H