#include <bdlb_bitutil.h>
List of all members.
Detailed Description
This utility struct
provides a namespace for a set of bit-level, stateless functions that operate on the built-in 32- and 64-bit integer types uint32_t
and uint64_t
, respectively.
See Component bdlb_bitutil
Member Typedef Documentation
Member Function Documentation
static bool bdlb::BitUtil::isBitSet |
( |
uint32_t |
value, |
|
|
int |
index | |
|
) |
| | [static] |
static bool bdlb::BitUtil::isBitSet |
( |
uint64_t |
value, |
|
|
int |
index | |
|
) |
| | [static] |
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)
.
static int bdlb::BitUtil::log2 |
( |
uint32_t |
value |
) |
[static] |
static int bdlb::BitUtil::log2 |
( |
uint64_t |
value |
) |
[static] |
Return the base-2 logarithm of the specified value
rounded up to the nearest integer. The behavior is undefined unless 0 < value
.
static int bdlb::BitUtil::numBitsSet |
( |
uint32_t |
value |
) |
[static] |
static int bdlb::BitUtil::numBitsSet |
( |
uint64_t |
value |
) |
[static] |
Return the number of 1 bits in the specified value
.
static int bdlb::BitUtil::numLeadingUnsetBits |
( |
uint32_t |
value |
) |
[static] |
static int bdlb::BitUtil::numLeadingUnsetBits |
( |
uint64_t |
value |
) |
[static] |
Return the number of consecutive 0 bits starting from the most-significant bit in the specified value
.
static int bdlb::BitUtil::numTrailingUnsetBits |
( |
uint32_t |
value |
) |
[static] |
static int bdlb::BitUtil::numTrailingUnsetBits |
( |
uint64_t |
value |
) |
[static] |
Return the number of consecutive 0 bits starting from the least-significant bit in the specified value
.
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
.
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))
template<class INTEGER >
static int bdlb::BitUtil::sizeInBits |
( |
INTEGER |
value |
) |
[static] |
Return the number of bits in the specified value
of the (template parameter) type INTEGER
.
static uint32_t bdlb::BitUtil::withBitCleared |
( |
uint32_t |
value, |
|
|
int |
index | |
|
) |
| | [static] |
static uint64_t bdlb::BitUtil::withBitCleared |
( |
uint64_t |
value, |
|
|
int |
index | |
|
) |
| | [static] |
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)
.
static uint32_t bdlb::BitUtil::withBitSet |
( |
uint32_t |
value, |
|
|
int |
index | |
|
) |
| | [static] |
static uint64_t bdlb::BitUtil::withBitSet |
( |
uint64_t |
value, |
|
|
int |
index | |
|
) |
| | [static] |
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)
.
The documentation for this struct was generated from the following file: