Antkeeper  0.0.1
Namespaces | Functions
bit-math.hpp File Reference
#include <stdint.h>

Go to the source code of this file.

Namespaces

 bit
 Bitwise math.
 

Functions

template<class T >
constexpr T bit::compress (T x) noexcept
 Compresses the even bits of a value into the lower half, then clears the upper half. More...
 
template<class T >
constexpr int bit::count (T x) noexcept
 Returns the number of set bits in a value, known as a population count or Hamming weight. More...
 
template<class T >
constexpr T bit::crossover (T a, T b, int i) noexcept
 Performs a single-point crossover between two values. More...
 
template<class T >
constexpr T bit::crossover_n (T a, T b, T mask) noexcept
 Performs an n-point crossover between two values. More...
 
template<class T >
constexpr T bit::deposit (T x, T mask) noexcept
 Reads bits from the least significant bits of a value and returns them in the positions marked by a mask. More...
 
template<class T >
constexpr T bit::desegregate (T x) noexcept
 Interleaves bits of the lower and upper halves of a value. More...
 
template<class T >
constexpr int bit::difference (T x, T y) noexcept
 Returns the number of differing bits between two values, known as Hamming distance. More...
 
template<class T >
constexpr T bit::expand (T x) noexcept
 Moves bits from the lower half of a value to occupy all even bits, and clears all odd bits. More...
 
template<class T >
constexpr T bit::extract (T x, T mask) noexcept
 Reads bits from a value in the positions marked by a mask and returns them in the least significant bits. More...
 
template<class T >
constexpr T bit::flip (T x, int i) noexcept
 Flips a single bit in a value. More...
 
template<class T , class U = T>
constexpr U bit::interleave (T a, T b) noexcept
 Returns a value with even bits containing the first value's lower half, and odd bits containing the second value's lower half. More...
 
template<class T >
constexpr T bit::merge (T a, T b, T mask) noexcept
 Merges the bits of two values using a bit mask. More...
 
template<class T >
constexpr T bit::parity (T x) noexcept
 Returns the parity of a value. More...
 
template<class T >
constexpr T bit::segregate (T x) noexcept
 Segregates the odd and even bits of a value. More...
 
template<class T >
constexpr T bit::swap_adjacent (T x) noexcept
 Swaps the each odd bit with its following even bit. More...
 
std::uint16_t bit::swap16 (std::uint16_t x) noexcept
 Swaps the byte order of an unsigned 16-bit number. More...
 
std::int16_t bit::swap16 (std::int16_t x) noexcept
 Swaps the byte order of a signed 16-bit number. More...
 
std::uint32_t bit::swap32 (std::uint32_t x) noexcept
 Swaps the byte order of an unsigned 32-bit number. More...
 
std::int32_t bit::swap32 (std::int32_t x) noexcept
 Swaps the byte order of a signed 32-bit number. More...
 
std::uint64_t bit::swap64 (std::uint64_t x) noexcept
 Swaps the byte order of an unsigned 64-bit number. More...
 
std::int64_t bit::swap64 (std::int64_t x) noexcept
 Swaps the byte order of a signed 64-bit number. More...