BloombergLP::bdlb::BitUtil::roundUpToBinaryPower

Return the least power of 2 not less than value.

Synopsis

Declared in <bdlb_bitutil.h>

static
unsigned int
roundUpToBinaryPower(unsigned int value);

Description

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))

Return Value

least power of 2 not less than value, or 0 on failure

Parameters

NameDescription
valuevalue to round up to a power of 2