aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/int128/int128_util.h
blob: b3208eaed330bc8f610230a74d83955bd2a3a4f1 (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); 
    } 
}