Add math helper: fast fmod
This commit is contained in:
parent
caf9af07ae
commit
4d20f7722a
1 changed files with 14 additions and 0 deletions
|
|
@ -139,6 +139,20 @@ constexpr T clamp(T v, T lo, T hi)
|
||||||
return max(min(v, hi), lo);
|
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>
|
template <int Increment = 1, class T>
|
||||||
inline CXX14_CONSTEXPR void incrementAll(T& only)
|
inline CXX14_CONSTEXPR void incrementAll(T& only)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue