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

Function MostSignificantBit

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

Source from the content-addressed store, hash-verified

104// Find the bit position of the most significant bit (0-based), or -1 if there were no bits set.
105template <typename T>
106constexpr ssize_t MostSignificantBit(T value) {
107 static_assert(std::is_integral<T>::value, "T must be integral");
108 static_assert(std::is_unsigned<T>::value, "T must be unsigned");
109 static_assert(std::numeric_limits<T>::radix == 2, "Unexpected radix!");
110 return (value == 0) ? -1 : std::numeric_limits<T>::digits - 1 - CLZ(value);
111}
112
113// Find the bit position of the least significant bit (0-based), or -1 if there were no bits set.
114template <typename T>

Callers 1

MinimumBitsToStoreFunction · 0.85

Calls 1

CLZFunction · 0.85

Tested by

no test coverage detected