Integer.lowestOneBit() method in Java


The method Integer.lowestOneBit() returns an int value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in the specified int value.

Here we have a decimal value 294, whose binary is −

100100110

The lowest one bit is calculated using the lowestOneBit() method in Java.

Example

 Live Demo

public class Demo {
   public static void main(String []args) {
      // binary 100100110
      int dec = 294;
      System.out.println("Count of one bits = " + Integer.bitCount(dec));
      System.out.println("Lowest one bit: " + Integer.lowestOneBit(dec));
   }
}

Output

Count of one bits = 4
Lowest one bit: 2

Updated on: 26-Jun-2020

62 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements