BDE 4.14.0 Production release
|
#include <bdlb_bitutil.h>
Public Types | |
typedef bsl::uint32_t | uint32_t |
typedef bsl::uint64_t | uint64_t |
Public Member Functions | |
template<class TYPE > | |
int | sizeInBits (TYPE) |
Static Public Member Functions | |
static bool | isBitSet (unsigned int value, int index) |
static bool | isBitSet (unsigned long value, int index) |
static bool | isBitSet (unsigned long long value, int index) |
static int | log2 (unsigned int value) |
static int | log2 (unsigned long value) |
static int | log2 (unsigned long long value) |
static int | numBitsSet (unsigned int value) |
static int | numBitsSet (unsigned long value) |
static int | numBitsSet (unsigned long long value) |
Return the number of 1 bits in the specified value . | |
static int | numLeadingUnsetBits (unsigned int value) |
static int | numLeadingUnsetBits (unsigned long value) |
static int | numLeadingUnsetBits (unsigned long long value) |
static int | numTrailingUnsetBits (unsigned int value) |
static int | numTrailingUnsetBits (unsigned long value) |
static int | numTrailingUnsetBits (unsigned long long value) |
static unsigned int | roundUp (unsigned int value, unsigned int boundary) |
static unsigned long | roundUp (unsigned long value, unsigned long boundary) |
static unsigned long long | roundUp (unsigned long long value, unsigned long long boundary) |
static unsigned int | roundUpToBinaryPower (unsigned int value) |
static unsigned long | roundUpToBinaryPower (unsigned long value) |
static unsigned long long | roundUpToBinaryPower (unsigned long long value) |
template<class INTEGER > | |
static int | sizeInBits (INTEGER value=0) |
static unsigned int | withBitCleared (unsigned int value, int index) |
static unsigned long | withBitCleared (unsigned long value, int index) |
static unsigned long long | withBitCleared (unsigned long long value, int index) |
static unsigned int | withBitSet (unsigned int value, int index) |
static unsigned long | withBitSet (unsigned long value, int index) |
static unsigned long long | withBitSet (unsigned long long value, int index) |
This utility struct
provides a namespace for a set of bit-level, stateless functions that operate on the built-in 32- and 64-bit unsigned integer types.
typedef bsl::uint32_t bdlb::BitUtil::uint32_t |
typedef bsl::uint64_t bdlb::BitUtil::uint64_t |
|
inlinestatic |
|
inlinestatic |
Return true
if the bit in the specified value
at the specified index
is set to 1, and false
otherwise. The behavior is undefined unless 0 <= index < sizeInBits(value)
.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return the base-2 logarithm of the specified value
rounded up to the nearest integer. The behavior is undefined unless 0 < value
.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return the number of consecutive 0 bits starting from the most-significant bit in the specified value
.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return the number of consecutive 0 bits starting from the least-significant bit in the specified value
.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return the least multiple of the specified boundary
that is greater than or equal to the specified value
, and 0 if 0 == value
or the conversion was not successful. The behavior is undefined unless 1 == numBitsSet(boundary)
. Note that the conversion will succeed if and only if 0 == value % boundary
or (1 << sizeInBits(value)) > (value / boundary + 1) * boundary
.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return the least power of 2 that is greater than or equal to the specified value
, and 0 if the conversion was not successful. Note that the conversion will succeed if and only if 0 < value <= (1 << (sizeInBits(value) - 1))
|
inlinestatic |
|
static |
Return the number of bits in the specified value
of the (template parameter) type INTEGER
.
|
inline |
|
inlinestatic |
|
inlinestatic |
Return the result of replacing the bit at the specified index
in the specified value
with 0, transferring all other bits from value
unchanged. The behavior is undefined unless 0 <= index < sizeInBits(value)
.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return the result of replacing the bit at the specified index
in the specified value
with 1, transferring all other bits from value
unchanged. The behavior is undefined unless 0 <= index < sizeInBits(value)
.
|
inlinestatic |