Add idiv & imod functions
This commit is contained in:
parent
c835925ca7
commit
ee2f5960f4
1 changed files with 12 additions and 0 deletions
|
|
@ -118,4 +118,16 @@ namespace psemek::geom
|
|||
return std::atan2(y, x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T idiv(T x, T m)
|
||||
{
|
||||
return (x >= 0) ? (x / m) : -((- x + m - 1) / m);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T imod(T x, T m)
|
||||
{
|
||||
return x - m * idiv(x, m);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue