java.lang.Long.highestOneBit()


java.lang.Long.highestOneBit()

package com.codingdict;



import java.lang.*;



public class LongDemo {



   public static void main(String[] args) {



      long l = 220;

      System.out.println("Number = " + l);



      /* returns the string representation of the unsigned long value 

         represented by the argument in binary (base 2) */

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



      // returns the number of one-bits 

      System.out.println("Number of one bits = " + Long.bitCount(l));



      /* returns a long value with at most a single one-bit, in the position 

         of the highest-order ("leftmost") one-bit in the specified int value */ 

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

   }

}