Floating-point comparison helpers for SGMath<T>

Implemented using numeric_limits::epsilon and std::abs, fingers
crossed this is sufficiently portable!
This commit is contained in:
James Turner
2018-01-26 11:29:18 +00:00
parent 5cb2360985
commit 8621925e75

View File

@@ -155,6 +155,12 @@ public:
{
return std::isnan(v);
}
static bool eq(const T& a, const T& b, const T& epsilon = SGLimits<T>::epsilon())
{ return std::abs(a - b) < epsilon; }
static bool neq(const T& a, const T& b, const T& epsilon = SGLimits<T>::epsilon())
{ return !eq(a, b, epsilon); }
};
#endif