Class BitHacks

  • All Implemented Interfaces:
    java.io.Serializable

    public class BitHacks
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long serialVersionUID  
    • Constructor Summary

      Constructors 
      Constructor Description
      BitHacks()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean IsPowerOfTwo​(int uiValue)
      Deterimes if the input is an exact power of two.
      static int Log2OfPowerOfTwo​(int uiPowerOfTwo)
      Returns the Log2 of an integer that is a power of two.
      • Methods inherited from class java.lang.Object

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

      • BitHacks

        public BitHacks()
    • Method Detail

      • IsPowerOfTwo

        public static boolean IsPowerOfTwo​(int uiValue)
        Deterimes if the input is an exact power of two.
        Parameters:
        uiValue -
        Returns:
        true if the input is an exact power of two, false otherwise.
      • Log2OfPowerOfTwo

        public static int Log2OfPowerOfTwo​(int uiPowerOfTwo)
        Returns the Log2 of an integer that is a power of two.
        Parameters:
        uiPowerOfTwo - int must be an exact power of two
        Returns:
        the Log2 value of the input parameter.