Long.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 long} value. Returns 64 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 long} values x: <ul> <li>floor(log<sub>2</sub>(x)) = {@code 63 - numberOfLeadingZeros(x)} <li>ceil(log<sub>2</sub>(x)) = {@code 64 - 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 long} value, or 64 if the value is equal to zero.

class Long
static
int
numberOfLeadingZeros
(
long i
)

Meta