Add math::fmod that works for negative inputs

This commit is contained in:
Nikita Lisitsa 2025-01-30 12:37:48 +03:00
parent adcf761243
commit b01c594cba

View file

@ -174,6 +174,12 @@ namespace psemek::math
return (x / y) + ((x % y) == 0 ? 0 : 1);
}
template <typename T>
T fmod(T x, T m)
{
return (x >= 0) ? std::fmod(x, m) : (m - std::fmod(-x, m));
}
template <typename T>
bool make_min(T & target, T const & source)
{