MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / IsPowerOfTwo

Function IsPowerOfTwo

Bcore/src/main/cpp/base/bit_utils.h:144–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142
143template<typename T>
144constexpr bool IsPowerOfTwo(T x) {
145 static_assert(std::is_integral<T>::value, "T must be integral");
146 // TODO: assert unsigned. There is currently many uses with signed values.
147 return (x & (x - 1)) == 0;
148}
149
150template<typename T>
151constexpr int WhichPowerOf2(T x) {

Callers 4

IsFirstBitSetMethod · 0.85
WhichPowerOf2Function · 0.85
RoundDownFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected