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

Function TruncToPowerOfTwo

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

Source from the content-addressed store, hash-verified

135// Return highest possible N - a power of two - such that val >= N.
136template <typename T>
137constexpr T TruncToPowerOfTwo(T val) {
138 static_assert(std::is_integral<T>::value, "T must be integral");
139 static_assert(std::is_unsigned<T>::value, "T must be unsigned");
140 return (val != 0) ? static_cast<T>(1u) << (BitSizeOf<T>() - CLZ(val) - 1u) : 0;
141}
142
143template<typename T>
144constexpr bool IsPowerOfTwo(T x) {

Callers

nothing calls this directly

Calls 1

CLZFunction · 0.85

Tested by

no test coverage detected