Java Integer numberOfTrailingZeros() MethodThe numberOfTrailingZeros() method is a method of Integer class under java.lang package. This method returns the total number of zero bits following the lowest-order ("rightmost") one's-bit in the two's complement binary representation of the specified integer value i.e. it converts int value to Binary then considers the right-most one bit and return total number of zero bits following it. In other words, if the specified integer value has no one-bits or is equal to zero in its two's complement representation then it will return 32. Exaplanation:Syntax:Following is the declaration of numberOfTrailingZeros() method: Parameter:
Returns:The numberOfTrailingZeros() method returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified integer value, or 32 if the value is equal to zero. Exceptions:NA Compatibility Version:Java 1.5 and above Example 1Output: Trailing Zero's: 1 Example 2Output: Binary equivalent: 111000 Number of Trailing Zeros: 3 Example 3Output: Enter the desired Integer value: 52 Binary equivalent: 110100 Number of Trailing Zeros: 2 Example 4Output: Input Number = -15 Number of Trailing Zeros = 0 Example 5Output: Trailing Zero's: 32 Next TopicJava-integer-parseunsignedint-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India