Add math::fmod that works for negative inputs
This commit is contained in:
parent
adcf761243
commit
b01c594cba
1 changed files with 6 additions and 0 deletions
|
|
@ -174,6 +174,12 @@ namespace psemek::math
|
||||||
return (x / y) + ((x % y) == 0 ? 0 : 1);
|
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>
|
template <typename T>
|
||||||
bool make_min(T & target, T const & source)
|
bool make_min(T & target, T const & source)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue