Java Integer highestOneBit() MethodThe highestOneBit() method is a method of Integer class under java.lang package. This method returns int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in the specified int value. If the specified value has no one-bits or is equal to zero in its two's complement binary representation, it returns zero. Syntax:Following is the declaration of highestOneBit() method: Parameter:
|
The highestOneBit() method returns an int value with a single one-bit, in the position of the highest-order one-bit in the specified value, or zero if the specified value is itself equal to zero.
NA
Java 1.5 and above
Output:
Integer value in the position of the highest-order one-bit: 16
Output:
Enter the desired value: 15 Integer value in the position of the highest-order one-bit: 8
Output:
Input Number is: 25 Highest 1-bit of the given integer is: 16 Input Number is = -20 Highest one bit of the given integer is = -2147483648
Output:
Input Number: 114 Binary Equivalent: 1110010 Total Number of 1-bits: 4 Integer Value of Highest 1-bit: 64
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