Class SerialNumber16

java.lang.Object
com.io7m.jserial.core.SerialNumber16
All Implemented Interfaces:
SerialNumberIntType

public final class SerialNumber16 extends Object implements SerialNumberIntType
An implementation of 16-bit serial number arithmetic.
  • Method Details

    • get

      public static SerialNumberIntType get()
      Returns:
      A serial number calculator
    • add

      public int add(int s0, int s1)
      Specified by:
      add in interface SerialNumberIntType
      Parameters:
      s0 - A serial number
      s1 - A serial number
      Returns:
      s0 + s1
    • bits

      public int bits()
      Specified by:
      bits in interface SerialNumberIntType
      Returns:
      The number of bits used
    • distance

      public int distance(int s0, int s1)
      Description copied from interface: SerialNumberIntType
      Calculate the signed distance between s0 and s1.
      Specified by:
      distance in interface SerialNumberIntType
      Parameters:
      s0 - A serial number
      s1 - A serial number
      Returns:
      The distance
    • compare

      public int compare(int s0, int s1)
      Description copied from interface: SerialNumberIntType
      Compare the serial numbers s0 and s1.
      Specified by:
      compare in interface SerialNumberIntType
      Parameters:
      s0 - A serial number
      s1 - A serial number
      Returns:
      0 if the serial numbers are equal, a value less than 0 if s0 < s1, or a value greater than 0 if s0 > s1
    • inRange

      public boolean inRange(int s0)
      Description copied from interface: SerialNumberIntType
      Determine serial number validity.
      Specified by:
      inRange in interface SerialNumberIntType
      Parameters:
      s0 - A serial number
      Returns:
      true iff s0 is in the range [0, (2 ^ bits()) - 1]