findLastSet

Synopsis

Declared in <folly/lang/Bits.h>

template<typename T>
constexpr
unsigned int
findLastSet(T const v);

Description

Return the 1‐based index of the most significant bit which is set. For x > 0, findLastSet(x) == 1 + floor(log2(x)).

Return Value

The 1‐based index of the most significant set bit, or 0 if v == 0.

Parameters

Name

Description

v

The integral value to examine.

Created with MrDocs