<bit>

#include <boost/int128/bit.hpp>

The following are functions analogous to those found in C++20 <bit> header, but for boost::int128::uint128_t. None of these functions apply to signed integral types, and thus none have overloads for boost::int128::int128_t. All of these functions are available using C++14 like the rest of the library.

has_single_bit

Checks if x is an integral power of two. Returns true if x is a power of two; otherwise false

namespace boost {
namespace int128 {

constexpr bool has_single_bit(uint128_t x) noexcept;

} // namespace int128
} // namespace boost

countl_zero

Returns the number of consecutive 0 bits in the value x, starting from the most significant.

namespace boost {
namespace int128 {

constexpr int countl_zero(uint128_t x) noexcept;

} // namespace int128
} // namespace boost

countl_one

Returns the number of consecutive 1 bits in the value x, starting from the most significant.

namespace boost {
namespace int128 {

constexpr int countl_one(uint128_t x) noexcept;

} // namespace int128
} // namespace boost

bit_width

If x is not zero, returns the number of bits needed to store the value x. If x is zero, returns 0

namespace boost {
namespace int128 {

constexpr int bit_width(uint128_t x) noexcept;

} // namespace int128
} // namespace boost

bit_ceil

Returns the smallest integral power of two that is not smaller than x.

namespace boost {
namespace int128 {

constexpr uint128_t bit_ceil(uint128_t x) noexcept;

} // namespace int128
} // namespace boost

bit_floor

Returns the largest integral power of two that is not greater than x. If x is 0 then returns 0.

namespace boost {
namespace int128 {

constexpr uint128_t bit_floor(uint128_t x) noexcept;

} // namespace int128
} // namespace boost

countr_zero

Returns the number of consecutive 0 bits in the value x, starting from the least significant.

namespace boost {
namespace int128 {

constexpr int countr_zero(uint128_t x) noexcept;

} // namespace int128
} // namespace boost

countr_one

Returns the number of consecutive 1 bits in the value x, starting from the least significant.

namespace boost {
namespace int128 {

constexpr int countr_one(uint128_t x) noexcept;

} // namespace int128
} // namespace boost

rotl

Computes the result of bitwise left-rotating the value of x by s positions. This operation is also known as a left circular shift.

namespace boost {
namespace int128 {

constexpr uint128_t rotl(uint128_t x, int s) noexcept;

} // namespace int128
} // namespace boost

rotr

Computes the result of bitwise right-rotating the value of x by s positions. This operation is also known as a right circular shift.

namespace boost {
namespace int128 {

constexpr uint128_t rotr(uint128_t x, int s) noexcept;

} // namespace int128
} // namespace boost

popcount

Returns the number of 1 bits in x.

namespace boost {
namespace int128 {

constexpr int popcount(uint128_t x) noexcept;

} // namespace int128
} // namespace boost

byteswap

Reverses the bytes in the given integer value x.

namespace boost {
namespace int128 {

constexpr uint128_t byteswap(uint128_t x) noexcept;

} // namespace int128
} // namespace boost