aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/int128/int128_util.h
blob: 7a5ca2c250295b4c05b5515c54e3331e7eb14572 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#pragma once

#include <util/generic/bitops.h>
#include <limits>

namespace NPrivateInt128 {
    // will be moved to util/ later
    template <typename T>
    constexpr unsigned CountLeadingZeroBits(const T value) {
        if (value == 0) {
            return std::numeric_limits<std::make_unsigned_t<T>>::digits;
        }
        return std::numeric_limits<std::make_unsigned_t<T>>::digits - GetValueBitCount(value);
    }
}