Integer.numberOfLeadingZeros

Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified {@code int} value. Returns 32 if the specified value has no one-bits in its two's complement representation, in other words if it is equal to zero.

<p>Note that this method is closely related to the logarithm base 2. For all positive {@code int} values x: <ul> <li>floor(log!(sub)2</sub>(x)) = {@code 31 - numberOfLeadingZeros(x)} <li>ceil(log!(sub)2</sub>(x)) = {@code 32 - numberOfLeadingZeros(x - 1)} </ul>

@param i the value whose number of leading zeros is to be computed @return the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified {@code int} value, or 32 if the value is equal to zero.

class Integer
static
int
numberOfLeadingZeros
(
int i
)

Meta