Count the number of ones from the most significant bit to the first zero bit.

Synopsis

Declared in <llvm/ADT/bit.h>

template<typename T>
[[nodiscard]]
int
countl_one(T Value);

Description

Ex. countl_one(0xFF0FFF00) == 8. Only unsigned integral types are allowed.

Returns std::numeric_limits<T>::digits on an input of all ones.

Return Value

Leading one count, or std::numeric_limits<T>::digits if all bits are set.

Note

The return value should not be discarded.

Parameters

Name

Description

Value

Unsigned value to scan from the most significant bit.

Created with MrDocs