Constexpr integer math, such as division that refuses to compile if the division has a remainder.
More...
|
template<typename T , typename Q > |
constexpr auto | sp::divRoundUp (T x, Q y) |
| Divide x by y, rounding up. More...
|
|
template<typename T , typename Q > |
constexpr auto | sp::roundUp (T x, Q to) |
| Round x up to the next multiple of to More...
|
|
template<typename T , typename Q > |
constexpr auto | sp::roundDown (T x, Q to) |
| Round x down to the next multiple of to More...
|
|
template<typename T > |
constexpr auto | sp::nextPowerOfTwo (T x) |
| Get the next power of two >= x. More...
|
|
constexpr int | sp::intSqrt (int n) |
| Compile-time integer square root, hilariously. More...
|
|
template<int X, int Y> |
constexpr int | sp::divExact () |
| Compile-time pedantic divide. More...
|
|
template<typename IntT > |
constexpr int | sp::log2 (IntT x) |
| Log base 2. More...
|
|
template<typename T > |
constexpr T | sp::gcd (T a, T b) |
| Greatest common divisor, evaluated at compile-time. More...
|
|
template<typename T > |
constexpr T | sp::lcm (T a, T b) |
|
Constexpr integer math, such as division that refuses to compile if the division has a remainder.
◆ divExact()
template<int X, int Y>
constexpr int sp::divExact |
( |
| ) |
|
|
constexpr |
Compile-time pedantic divide.
◆ divRoundUp()
template<typename T , typename Q >
constexpr auto sp::divRoundUp |
( |
T |
x, |
|
|
Q |
y |
|
) |
| |
|
constexpr |
Divide x by y, rounding up.
◆ gcd()
template<typename T >
constexpr T sp::gcd |
( |
T |
a, |
|
|
T |
b |
|
) |
| |
|
constexpr |
Greatest common divisor, evaluated at compile-time.
◆ intSqrt()
constexpr int sp::intSqrt |
( |
int |
n | ) |
|
|
constexpr |
Compile-time integer square root, hilariously.
◆ log2()
template<typename IntT >
constexpr int sp::log2 |
( |
IntT |
x | ) |
|
|
constexpr |
◆ nextPowerOfTwo()
template<typename T >
constexpr auto sp::nextPowerOfTwo |
( |
T |
x | ) |
|
|
constexpr |
Get the next power of two >= x.
◆ roundDown()
template<typename T , typename Q >
constexpr auto sp::roundDown |
( |
T |
x, |
|
|
Q |
to |
|
) |
| |
|
constexpr |
Round x down to the next multiple of to
◆ roundUp()
template<typename T , typename Q >
constexpr auto sp::roundUp |
( |
T |
x, |
|
|
Q |
to |
|
) |
| |
|
constexpr |
Round x up to the next multiple of to