13 #ifndef ML_NUMERIC_HELPERS_H
14 #define ML_NUMERIC_HELPERS_H
25 template <
typename T, std::
size_t N> constexpr
T convertTo(
const char (&t)[
N])
27 static_assert(
N - 1 ==
sizeof(
T),
"Illegal character sequence for type T");
29 for (
auto index = 0u; index <
N - 1; ++index)
30 result = (result << 8) + t[index];
45 static_assert(std::is_floating_point_v<T>,
"Deduced type T should be a floating point type");
48 auto diff = std::fabs(x - y);
49 if (diff <= absoluteEpsilon)
54 T largest = std::max(x, y);
56 if (diff <= largest * relativeEpsilon)
Main documentation file for ML users and developers.
constexpr T convertTo(const char(&t)[N])
constexpr bool almostEqualRelativeAndAbs(T x, T y, T absoluteEpsilon, T relativeEpsilon=std::numeric_limits< T >::epsilon())