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

Function NextPower2

cpp/src/arrow/util/bit_util.h:56–68  ·  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

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

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