int128_util.h 428 B

123456789101112131415
  1. #pragma once
  2. #include <util/generic/bitops.h>
  3. #include <limits>
  4. namespace NPrivateInt128 {
  5. // will be moved to util/ later
  6. template <typename T>
  7. constexpr unsigned CountLeadingZeroBits(const T value) {
  8. if (value == 0) {
  9. return std::numeric_limits<std::make_unsigned_t<T>>::digits;
  10. }
  11. return std::numeric_limits<std::make_unsigned_t<T>>::digits - GetValueBitCount(value);
  12. }
  13. }