Class BinaryUtil


  • public class BinaryUtil
    extends Object
    Utilities for binary value encoding.
    • Constructor Detail

      • BinaryUtil

        public BinaryUtil()
    • Method Detail

      • zigzagEncode

        public static int zigzagEncode​(int value)
        Zig-zag encodes the given int producing a small positive number for inputs with small absolute value.
        Parameters:
        value - The value to encode.
        Returns:
        The zig-zag encoded value.
      • zigzagEncode

        public static long zigzagEncode​(long value)
        Zig-zag encodes the given long producing a small positive number for inputs with small absolute value.
        Parameters:
        value - The value to encode.
        Returns:
        The zig-zag encoded value.
      • zigzagDecode

        public static int zigzagDecode​(int value)
        Decodes the result of zigzagEncode(int) to its original signed value.
        Parameters:
        value - The value to decode.
        Returns:
        The zig-zag decoded value.
      • zigzagDecode

        public static long zigzagDecode​(long value)
        Decodes the result of zigzagEncode(long) to its original signed value.
        Parameters:
        value - The value to decode.
        Returns:
        The zig-zag decoded value.