Add math helper: fast fmod

This commit is contained in:
Jean Pierre Cimalando 2020-09-29 02:40:38 +02:00
parent caf9af07ae
commit 4d20f7722a

View file

@ -139,6 +139,20 @@ constexpr T clamp(T v, T lo, T hi)
return max(min(v, hi), lo);
}
/**
* @brief Compute the floating-point remainder (fmod)
*
* @tparam T
* @param x
* @param m
* @return T
*/
template <class T>
inline constexpr T fastFmod(T x, T m)
{
return x - m * static_cast<int>(x / m);
}
template <int Increment = 1, class T>
inline CXX14_CONSTEXPR void incrementAll(T& only)
{