MCPcopy Create free account
hub / github.com/apache/arrow / NextPower2

Function NextPower2

cpp/src/arrow/util/bit_util.h:59–71  ·  view source on GitHub ↗

Returns the smallest power of two that contains v. If v is already a power of two, it is returned as is.

Source from the content-addressed store, hash-verified

57// Returns the smallest power of two that contains v. If v is already a
58// power of two, it is returned as is.
59static inline int64_t NextPower2(int64_t n) {
60 // Taken from
61 // http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
62 n--;
63 n |= n >> 1;
64 n |= n >> 2;
65 n |= n >> 4;
66 n |= n >> 8;
67 n |= n >> 16;
68 n |= n >> 32;
69 n++;
70 return n;
71}
72
73constexpr bool IsMultipleOf64(int64_t n) { return (n & 63) == 0; }
74

Callers 8

MakeSimilarIntDictFodderFunction · 0.85
HashTableMethod · 0.85
TESTFunction · 0.85
CommonNumericFunction · 0.85
EnsureDecodeBufferMethod · 0.85
OptimalNumOfBitsFunction · 0.85
InitMethod · 0.85
UpdateCapacityMethod · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68