Class Unsigned16

java.lang.Object
com.io7m.jintegers.Unsigned16

public final class Unsigned16 extends Object
Unsigned 16-bit integer handling.
  • Method Details

    • packToBufferBigEndian

      public static ByteBuffer packToBufferBigEndian(int i, ByteBuffer r, int index)

      Pack i into a byte buffer r using a big-endian encoding such that the most significant byte is in r[index].

      Parameters:
      r - The buffer.
      i - The value to be packed.
      index - The starting index.
      Returns:
      r
    • packToBufferLittleEndian

      public static ByteBuffer packToBufferLittleEndian(int i, ByteBuffer r, int index)

      Pack i into a byte buffer r using a little-endian encoding such that the least significant byte is in r[index].

      Parameters:
      r - The buffer.
      i - The value to be packed.
      index - The starting index.
      Returns:
      r
    • packToBuffer

      public static void packToBuffer(int x, ByteBuffer data, int index)
      Pack an unsigned 16-bit integer into the buffer.
      Parameters:
      x - The value.
      data - The buffer.
      index - The starting index.
    • unpackFromBufferBigEndian

      public static int unpackFromBufferBigEndian(ByteBuffer buffer, int index)

      Unpack an integer from buffer assuming a big-endian encoding such that the most significant byte is in b[index].

      Parameters:
      index - The starting index in the buffer.
      buffer - The buffer from which to unpack data.
      Returns:
      A 16 bit integer value.
    • unpackFromBuffer

      public static int unpackFromBuffer(ByteBuffer data, int index)
      Unpack an unsigned 16-bit integer from the buffer.
      Parameters:
      data - The buffer.
      index - The starting index.
      Returns:
      An unpacked integer value.
    • unpackFromBufferLittleEndian

      public static int unpackFromBufferLittleEndian(ByteBuffer buffer, int index)

      Unpack an integer from buffer assuming a little-endian encoding such that the least significant byte is in b[index].

      Parameters:
      index - The starting index
      buffer - The buffer from which to unpack data.
      Returns:
      A 16 bit integer value.