summary refs log tree commit diff
path: root/src/Math/Mod.hpp
blob: d686ad9d753f8fa1e69c6ff17cdce8868f592c04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#pragma once

namespace Math {

// Returns the least nonnegative remainder of a % b.
// Euclidian definition of modulo.
template <typename A, typename B>
auto mod(A a, B b) -> decltype(a % b) {
    return (a % b + b) % b;
}

}