The numberOfLeadingZeros()  method of Java Integer class returns the total number of zero bits preceding the highest-order one-bit in the 2’s complement binary representation of the specified int value.

 Syntax

public static int numberOfLeadingZeros (int i)

 Parameters

The parameter ‘i’ represents a value whose number of leading zeros is to be determined.

 Return Value

This method returns:

  • The Number of zero bits preceding the highest-order one-bit in the 2’s complement binary representation.
  • 32 if the value is equal to zero.

Example 1

Output

Example 2

Output

Example 3

Output

Pin It on Pinterest

Share This