Class Logs


  • public class Logs
    extends java.lang.Object
    simple utilities with logarithms
    • Constructor Summary

      Constructors 
      Constructor Description
      Logs()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int binaryLogUp​(int n)
      Binary log: finds the smallest power k such that 2^k >= n
      static int binaryLogUp​(long n)
      Binary log: finds the smallest power k such that 2^k >= n
      static boolean isPowerOf2​(int x)  
      static int log2​(int x)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Logs

        public Logs()
    • Method Detail

      • isPowerOf2

        public static boolean isPowerOf2​(int x)
        Returns:
        true iff x == 2^n for some integer n
      • log2

        public static int log2​(int x)
                        throws java.lang.IllegalArgumentException
        Parameters:
        x - where x == 2^n for some integer n
        Throws:
        java.lang.IllegalArgumentException
      • binaryLogUp

        public static int binaryLogUp​(int n)
        Binary log: finds the smallest power k such that 2^k >= n
      • binaryLogUp

        public static int binaryLogUp​(long n)
        Binary log: finds the smallest power k such that 2^k >= n