Java Data Type Tutorial - Java Long.highestOneBit(long i)








Syntax

Long.highestOneBit(long i) has the following syntax.

public static long highestOneBit(long i)

Example

In the following code shows how to use Long.highestOneBit(long i) method.

//from   w  w w. j  ava2  s  .  c  o m

public class Main {

   public static void main(String[] args) {

     long l = 100;
     System.out.println("Number = " + l);
    
     System.out.println("Binary = " + Long.toBinaryString(l));

     System.out.println("Lowest one bit = " + Long.highestOneBit(l));
   }
}

The code above generates the following result.