java.lang.Object
com.pnfsoftware.jeb.util.primitives.Longs

public class Longs extends Object
Utility methods for longs.
  • Constructor Details

    • Longs

      public Longs()
  • Method Details

    • fromInts

      public static long fromInts(int v0, int v1)
      Create a long from two ints. See toInts(long) for the reverse operation.
      Parameters:
      v0 -
      v1 -
      Returns:
    • toInts

      public static int[] toInts(long v)
      Create two ints from a long. See fromInts(int, int) for the reverse operation.
      Parameters:
      v -
      Returns:
      an array of two ints.
    • toUnsignedString

      public static String toUnsignedString(long value)
      Convert a long to its unsigned decimal string representation.
      Parameters:
      value -
      Returns:
    • toUnsignedBigInteger

      public static BigInteger toUnsignedBigInteger(long v)
      Convert a long treated as unsigned to a big integer.
      Parameters:
      v -
      Returns:
    • compareUnsigned

      public static int compareUnsigned(long x, long y)
      Compare two longs as unsigned.
      Parameters:
      x -
      y -
      Returns:
    • maxUnsigned

      public static long maxUnsigned(long x, long y)
      Retrieve the max of two longs treated as unsigned.
      Parameters:
      x -
      y -
      Returns:
    • minUnsigned

      public static long minUnsigned(long x, long y)
      Retrieve the min of two longs treated as unsigned.
      Parameters:
      x -
      y -
      Returns:
    • divUnsigned

      public static long divUnsigned(long dividend, long divisor)
      Divide two longs treated as unsigned.
      Parameters:
      dividend -
      divisor -
      Returns:
    • remUnsigned

      public static long remUnsigned(long dividend, long divisor)
      Get the division remainder of two longs treated as unsigned.
      Parameters:
      dividend -
      divisor -
      Returns:
    • formatHexCollection

      public static String formatHexCollection(Collection<Long> list)
      Uses a "0x" prefix, ", " separator.
      Parameters:
      list -
      Returns:
    • formatLongCollection

      public static String formatLongCollection(Collection<Long> collection, Integer radix, String pfx, String sfx, String separator)
      Format a collection of longs.
      Parameters:
      collection - collection of longs
      radix - optional, default=10
      pfx - optional, default=none
      sfx - optional, default=none
      separator - optional, default=", "
      Returns:
    • equals

      public static boolean equals(Long a, Long b)
      Safe equality.
      Parameters:
      a - may be null
      b - may be null
      Returns:
      true if both a and b are null or if their long values are equal
    • equals

      public static boolean equals(Long a, long b)
      Safe equality.
      Parameters:
      a - may be null
      b -
      Returns:
      true if a is not null and its long value equal to b
    • equals

      public static boolean equals(long a, Long b)
      Safe equality.
      Parameters:
      a -
      b - may be null
      Returns:
      true if b is not null and its long value equal to a
    • range

      public static Iterable<Long> range(long start, long end, long step)
      Generate an iterable range of integers.
      Parameters:
      start -
      end - exclusive
      step - increment (can be negative, cannot be zero)
      Returns:
    • range

      public static Iterable<Long> range(long start, long end)
      Generate an incremental range of integers.
      Parameters:
      start -
      end - exclusive
      Returns:
    • range

      public static Iterable<Long> range(long cnt)
      Generate an incremental range of integers from 0 to the provided count.
      Parameters:
      cnt -
      Returns: