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.


// ww w. jav  a  2s.  co 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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable