Supplemental Math Functions#
#include <dplx/cncr/math_supplement.hpp>
namespace dplx::cncr {}
-
template<typename T>
concept integer# Identifies the standard and extended integer types.
-
template<typename T>
concept signed_integer# Identifies the standard and extended signed integer types.
-
template<typename T>
concept unsigned_integer# Identifies the standard and extended unsigned integer types.
-
template<signed_integer T, signed_integer U>
constexpr auto div_ceil(T const dividend, U const divisor) noexcept -> std::common_type_t<T, U># - Returns:
\(\left\lceil \frac{dividend}{divisor} \right\rceil\)
-
template<unsigned_integer T, unsigned_integer U>
constexpr auto div_ceil(T const dividend, U const divisor) noexcept -> std::common_type_t<T, U># - Returns:
\(\left\lceil \frac{dividend}{divisor} \right\rceil\)
-
template<integer T, integer U>
constexpr auto round_up(T const value, U const multiple) noexcept -> std::common_type_t<T, U># - Returns:
\(multiple \cdot \left\lceil \frac{value}{multiple} \right\rceil\)
-
template<unsigned_integer T, unsigned_integer U>
constexpr auto round_up_p2(T const value, U const powerOf2) noexcept -> std::common_type_t<T, U># - Param:
powerOf2 must be of the form \(2^n\) whereas \(n \in \mathbb{N}\)
- Returns:
\(2^n \cdot \left\lceil \frac{value}{2^n} \right\rceil\)
-
template<integer T, integer U>
constexpr auto round_down(T const value, U const multiple) noexcept -> std::common_type_t<T, U># - Returns:
\(multiple \cdot \left\lfloor \frac{value}{multiple} \right\rfloor\)
-
template<unsigned_integer T, unsigned_integer U>
constexpr auto round_down_p2(T const value, U const powerOf2) noexcept -> std::common_type_t<T, U># - Param:
powerOf2 must be of the form \(2^n\) whereas \(n \in \mathbb{N}\)
- Returns:
\(2^n \cdot \left\lfloor \frac{value}{2^n} \right\rfloor\)
-
constexpr auto upow(unsigned long long x, unsigned long long e) noexcept -> unsigned long long#
- Returns:
\(x^e \mod 2^b\) whereas \(b\) is the size of unsigned long long in bits