Package 

Class Bits


  • 
    public class Bits
    
                        

    Utility definitions for bitwise operations.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static int SIZE_OF_INT
      public final static int SIZE_OF_LONG
    • Method Summary

      Modifier and Type Method Description
      static int intMaskOf(int i) Construct {@code int} mask with single bit set.
      static long longMaskOf(int i) Construct {@code long} mask with single bit set.
      static int intMaskOfRange(int i, int j) Construct {@code int} mask with range of bits set.
      static long longMaskOfRange(int i, int j) Construct {@code long} mask with range of bits set.
      static int sizeOfUnsigned(long v) Calculate size, in bits, of an unsigned value.
      • Methods inherited from class java.lang.Object

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

      • intMaskOf

         static int intMaskOf(int i)

        Construct {@code int} mask with single bit set.

        Parameters:
        i - position of bit to set
      • longMaskOf

         static long longMaskOf(int i)

        Construct {@code long} mask with single bit set.

        Parameters:
        i - position of bit to set
      • intMaskOfRange

         static int intMaskOfRange(int i, int j)

        Construct {@code int} mask with range of bits set.

        Parameters:
        i - position of first bit to set (inclusive)
        j - position of last bit to set (inclusive)
      • longMaskOfRange

         static long longMaskOfRange(int i, int j)

        Construct {@code long} mask with range of bits set.

        Parameters:
        i - position of first bit to set (inclusive)
        j - position of last bit to set (inclusive)
      • sizeOfUnsigned

         static int sizeOfUnsigned(long v)

        Calculate size, in bits, of an unsigned value.

        Parameters:
        v - unsigned value to calculate bit size of