The java.lang.Integer.numberOfLeadingZeros() method is used to return the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified int value. The method 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.

For all positive int values x:

• floor(log2(x)) = 31 - numberOfLeadingZeros(x)
• ceil(log2(x)) = 32 - numberOfLeadingZeros(x - 1)

### Parameters

 i Specify the value whose number of leading zeros is to be computed.

### Return Value

Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified int value, or 32 if the value is equal to zero.

NA.

### Example:

In the below example, the java.lang.Integer.numberOfLeadingZeros() method is used to return the number of zero bits preceding the leftmost one-bit in the two's complement binary representation of the given int value.

import java.lang.*;

public class MyClass {
public static void main(String[] args) {

//creating an int value
int x = 75;

//printing value of x, its binary