sandbox
Loading...
Searching...
No Matches
fast_mod.hpp
1
#ifndef LIBSBX_UTILITY_FAST_MOD_HPP_
2
#define LIBSBX_UTILITY_FAST_MOD_HPP_
3
4
#include <concepts>
5
#include <cmath>
6
7
namespace
sbx::utility {
8
19
template
<std::
unsigned
_
int
egral Type>
20
constexpr
auto
fast_mod(
const
Type value,
const
Type modulus)
noexcept
-> Type {
21
// return value - (value / modulus) * modulus;
22
return
value < modulus ? value : value % modulus;
23
}
24
25
template
<std::
float
ing_po
int
Type>
26
constexpr
auto
fast_mod(
const
Type value,
const
Type modulus)
noexcept
-> Type {
27
// return value - (value / modulus) * modulus;
28
return
value < modulus ? value : std::fmod(value, modulus);
29
}
30
31
}
// namespace sbx::utility
32
33
#endif
// LIBSBX_UTILITY_FAST_MOD_HPP_
libsbx-utility
libsbx
utility
fast_mod.hpp
Generated by
1.9.5