##// END OF EJS Templates
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
Renamed SqpRange to DateTimeRange, introduced VariableController2 to replace current implementation Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1346:d8cb4bff8c14
r1346:d8cb4bff8c14
Show More
Numeric.h
18 lines | 641 B | text/x-c | CLexer
#include <cmath>
#include <limits>
#include <type_traits>
#include <algorithm>
/*
taken from here https://en.cppreference.com/w/cpp/types/numeric_limits/epsilon
*/
template<class T>
typename std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type
almost_equal(T x, T y, int ulp)
{
// the machine epsilon has to be scaled to the magnitude of the values used
// and multiplied by the desired precision in ULPs (units in the last place)
return std::abs(x-y) <= std::numeric_limits<T>::epsilon() * std::abs(x+y) * ulp
// unless the result is subnormal
|| std::abs(x-y) < std::numeric_limits<T>::min();
}