14 std::string output(
"");
15 for(
size_t i = 31; i !=
SIZE_MAX ;--i){
27 size_t msb(uint32_t val){
28 const uint32_t mask[] = {
42 for (i = 0; i < 5; i++) {
43 int mi = lo + (hi - lo) / 2;
47 else if ((val & (mask[i] << lo)) != 0)
57 static const unsigned int MultiplyDeBruijnBitPosition[32] =
60 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
61 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
71 return MultiplyDeBruijnBitPosition[x];
77 val = val - ((val >> 1) & 0x55555555);
78 val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
79 return ((val + (val >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
91 return val & ~((1 << pos) - 1);
101 return val & (1<<31);
103 return val & ((1 << pos+1) - 1);