quality:correction
Integer rounding

The binary logarithm can be made into a function from integers and to integers by rounding it up or down. These two forms of integer binary logarithm are related by this formula:

The definition can be extended by defining ⌊ log 2 (0) ⌋ = − 1 {\displaystyle \lfloor \log _{2}(0)\rfloor =-1}. Extended in this way, this function is related to the number of leading zeros of the 32-bit unsigned binary representation of x, nlz(x).

The integer binary logarithm can be interpreted as the zero-based index of the most significant 1 bit in the input. In this sense it is the complement of the find first set operation, which finds the index of the least significant 1 bit. Many hardware platforms include support for finding the number of leading zeros, or equivalent operations, which can be used to quickly find the binary logarithm. The fls and flsl functions in the Linux kernel and in some versions of the libc software library also compute the binary logarithm (rounded up to an integer, plus one).