CatapultServer  v0.5.0.1 (Elephant)
IntegerMath.h File Reference
Include dependency graph for IntegerMath.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 catapult
 
 catapult::utils
 

Functions

template<typename T >
bool catapult::utils::CheckedAdd (T &value, T delta)
 Adds delta to value if and only if there is no overflow. More...
 
template<typename T , typename X = std::enable_if_t<std::is_integral_v<T>>>
constexpr T catapult::utils::GetNumBits ()
 Gets the number of bits in the specified type. More...
 
template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr T catapult::utils::Log2 (T value)
 Calculates log2(value). More...
 
uint64_t catapult::utils::Log2TimesPowerOfTwo (uint64_t value, uint64_t n)
 Calculates log2(value^(2^n)). More...
 
template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr T catapult::utils::Pow2 (T value)
 Calculates 2^(value). More...
 
template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr T catapult::utils::DivideAndGetRemainder (T &value, T divisor)
 Divides value by divisor and returns the remainder. More...
 
template<typename T , typename X = std::enable_if_t<std::is_unsigned_v<T>>>
constexpr bool catapult::utils::IsPowerMultiple (T lhs, T rhs, T base)
 Returns true if rhs is equal to lhs multipled by a power of base. More...