nPof2

Convinience function to return the ceiling to the next power of two of the given input.

@nogc
size_t
nPof2
(
size_t value
)

Examples

const size_t currentSeed = unpredictableSeed();
static if(vdebug){write("UT: nPof2.            "); writeln("seed: ", currentSeed);} 
rndGenInUse.seed(currentSeed); //initialize the random generator
const size_t M = uniform(1U,size_t.max/2, rndGenInUse); //set universe size to some integer. 

const auto pOfM = nPof2(M); 
assert((pOfM & (pOfM-1)) == 0); 
const auto check = powersOfTwo.until(nPof2(M), OpenRight.no).array; 
assert(M < check[$-1]); 
assert(M > check[$-2]);

Meta