Class BitUtil


  • public final class BitUtil
    extends Object
    A variety of high efficiency bit twiddling routines.
    • Method Detail

      • zigZagEncode

        public static int zigZagEncode​(int i)
        Same as zigZagEncode(long) but on integers.
      • zigZagEncode

        public static long zigZagEncode​(long l)
        Zig-zag encode the provided long. Assuming the input is a signed long whose absolute value can be stored on n bits, the returned value will be an unsigned long that can be stored on n+1 bits.
      • zigZagDecode

        public static int zigZagDecode​(int i)
        Decode an int previously encoded with zigZagEncode(int).
      • zigZagDecode

        public static long zigZagDecode​(long l)
        Decode a long previously encoded with zigZagEncode(long).