diff --git a/maths.hpp b/maths.hpp index 543ceed1..712cf7ab 100644 --- a/maths.hpp +++ b/maths.hpp @@ -385,6 +385,32 @@ namespace util { } + /////////////////////////////////////////////////////////////////////////// + // Modulus/etc + + // namespaced wrapper for `man 3 fmod` + template + constexpr + std::enable_if_t< + std::is_floating_point::value, T + > + mod (T x, T y) + { + return std::fmod (x, y); + } + + + template + constexpr + std::enable_if_t< + std::is_integral::value, T + > + mod (T x, T y) + { + return x % y; + } + + /////////////////////////////////////////////////////////////////////////////// // angles, trig template