Class Pow2


  • public final class Pow2
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Pow2()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isPowerOfTwo​(int value)
      Is this value a power of two.
      static int roundToPowerOfTwo​(int value)
      Find the next larger positive power of two value up from the given value.
      • Methods inherited from class java.lang.Object

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

      • Pow2

        private Pow2()
    • Method Detail

      • roundToPowerOfTwo

        public static int roundToPowerOfTwo​(int value)
        Find the next larger positive power of two value up from the given value. If value is a power of two then this value will be returned.
        Parameters:
        value - from which next positive power of two will be found.
        Returns:
        the next positive power of 2 or this value if it is a power of 2.
      • isPowerOfTwo

        public static boolean isPowerOfTwo​(int value)
        Is this value a power of two.
        Parameters:
        value - to be tested to see if it is a power of two.
        Returns:
        true if the value is a power of 2 otherwise false.