Class BitUtil


  • public final class BitUtil
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long align​(long value, int alignment)  
      static long ceilDiv​(long dividend, long divisor)  
      static boolean isPowerOfTwo​(int value)  
      static boolean isPowerOfTwo​(long value)  
      static int nearbyPowerOfTwo​(int x)  
      static long nearbyPowerOfTwo​(long x)  
      static int nextHighestPowerOfTwo​(int v)
      returns the next highest power of two, or the current value if it's already a power of two or zero
      static long nextHighestPowerOfTwo​(long v)
      returns the next highest power of two, or the current value if it's already a power of two or zero
      static int previousPowerOfTwo​(int v)
      returns the previous highest power of two, or the current value if it's already a power of two or zero
      static long previousPowerOfTwo​(long v)
      returns the previous highest power of two, or the current value if it's already a power of two or zero
      • Methods inherited from class java.lang.Object

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

      • isPowerOfTwo

        public static boolean isPowerOfTwo​(int value)
      • isPowerOfTwo

        public static boolean isPowerOfTwo​(long value)
      • previousPowerOfTwo

        public static int previousPowerOfTwo​(int v)
        returns the previous highest power of two, or the current value if it's already a power of two or zero
      • previousPowerOfTwo

        public static long previousPowerOfTwo​(long v)
        returns the previous highest power of two, or the current value if it's already a power of two or zero
      • nearbyPowerOfTwo

        public static int nearbyPowerOfTwo​(int x)
      • nearbyPowerOfTwo

        public static long nearbyPowerOfTwo​(long x)
      • nextHighestPowerOfTwo

        public static int nextHighestPowerOfTwo​(int v)
        returns the next highest power of two, or the current value if it's already a power of two or zero
      • nextHighestPowerOfTwo

        public static long nextHighestPowerOfTwo​(long v)
        returns the next highest power of two, or the current value if it's already a power of two or zero
      • align

        public static long align​(long value,
                                 int alignment)
      • ceilDiv

        public static long ceilDiv​(long dividend,
                                   long divisor)