Bit Operations
1.10.1¶
#include <std/bit.pat>
This namespace contains various bit-level operations
Functions¶
std::bit::popcount(u128 value) -> u128
1.10.1¶
Returns the number of 1 bits in “value”
Parameter |
Description |
---|---|
|
Integer value |
|
Number of bits of the value set to 1 |
std::bit::has_single_bit(u128 value) -> bool
1.10.1¶
Returns true if only a single bit is set in “value”
Parameter |
Description |
---|---|
|
Integer value |
|
True if only one bit is set in |
std::bit::bit_ceil(u128 value) -> u128
1.10.1¶
Calculates the smallest integral power of two that is not smaller than “value”
Parameter |
Description |
---|---|
|
Integer value |
|
Smallest integral power of two that is not smaller than |
std::bit::bit_floor(u128 value) -> u128
1.10.1¶
Calculates the largest integral power of two that is not greater than “value”
Parameter |
Description |
---|---|
|
Integer value |
|
Largest integral power of two that is not greater than |