author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
#ifndef __MATH_AUX_H |
sl@0 | 2 |
#define __MATH_AUX_H |
sl@0 | 3 |
|
sl@0 | 4 |
#include <limits> |
sl@0 | 5 |
|
sl@0 | 6 |
/* |
sl@0 | 7 |
* This function is not only used to compare floating point values with a tolerance, |
sl@0 | 8 |
* it also leads to ambiguity problems if the called functions do not have the |
sl@0 | 9 |
* right prototype. |
sl@0 | 10 |
*/ |
sl@0 | 11 |
template <class _Tp> |
sl@0 | 12 |
bool are_equals(_Tp val, _Tp ref) { |
sl@0 | 13 |
if (val < ref) { |
sl@0 | 14 |
return (ref - val) <= std::numeric_limits<_Tp>::epsilon(); |
sl@0 | 15 |
} |
sl@0 | 16 |
else { |
sl@0 | 17 |
return (val - ref) <= std::numeric_limits<_Tp>::epsilon(); |
sl@0 | 18 |
} |
sl@0 | 19 |
} |
sl@0 | 20 |
|
sl@0 | 21 |
#endif // __MATH_AUX_H |