Class CompareUtils

java.lang.Object
io.deephaven.base.CompareUtils

public class CompareUtils extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    compare(double a, double b)
     
    static int
    compare(long a, long b)
     
    static int
    compare(Object data1, Object data2)
     
    static int
    compareUnsigned(long a, long b)
     
    static int
    doubleCompare(double d1, double d2)
     
    static boolean
    doubleEquals(double x, double y)
     
    static boolean
    doubleEquals(double x, double y, double tolerance)
    You can't do double1 == double2 because floating point numbers are not exact values.
    static boolean
    doubleEquals2(double x, double y)
     
    static boolean
    doubleEquals2(double x, double y, double tolerance)
     
    static boolean
    doubleEqualsZero(double x)
     
    static boolean
    doubleEqualsZero(double x, double tolerance)
     
    static boolean
    doubleGreater(double x, double y)
     
    static boolean
    doubleGreater(double x, double y, double tolerance)
     
    static boolean
    doubleGreaterEqual(double x, double y)
     
    static boolean
    doubleGreaterEqual(double x, double y, double tolerance)
     
    static boolean
    doubleLess(double x, double y)
     
    static boolean
    doubleLess(double x, double y, double tolerance)
    You can't do double1 < double2 because floating point numbers are not exact values.
    static boolean
    doubleLessEqual(double x, double y)
     
    static boolean
    doubleLessEqual(double x, double y, double tolerance)
     
    static boolean
    doubleNotEquals(double x, double y)
     
    static boolean
    doubleNotEquals(double x, double y, double tolerance)
     
    static boolean
    doubleNotEquals2(double x, double y)
     
    static boolean
    doubleNotEquals2(double x, double y, double tolerance)
     
    static boolean
    EQ(double x, double y)
    You can't do double1 == double2 because floating point numbers are not exact values.
    static boolean
    EQ2(double x, double y)
     
    static boolean
    equals(Object data1, Object data2)
     
    static boolean
    GE(double x, double y)
     
    static boolean
    GT(double x, double y)
    You can't do double1 > double2 because floating point numbers are not exact values.
    static boolean
    LE(double x, double y)
     
    static boolean
    LT(double x, double y)
     
    static boolean
    NE(double x, double y)
    Since logical comparison of double values considering error is effectively a three-value logic, you can't really do !equals when you mean notEquals.
    static boolean
    NE2(double x, double y)
     
    static boolean
    Returns true if the given objects are both null, or equal by the first object's equals(java.lang.Object, java.lang.Object) method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CompareUtils

      public CompareUtils()
  • Method Details

    • compare

      public static int compare(Object data1, Object data2)
    • compare

      public static int compare(long a, long b)
    • compareUnsigned

      public static int compareUnsigned(long a, long b)
    • compare

      public static int compare(double a, double b)
    • equals

      public static boolean equals(Object data1, Object data2)
    • nullSafeEquals

      public static boolean nullSafeEquals(Object left, Object right)
      Returns true if the given objects are both null, or equal by the first object's equals(java.lang.Object, java.lang.Object) method.
    • EQ

      public static boolean EQ(double x, double y)
      You can't do double1 == double2 because floating point numbers are not exact values. Just make sure that x-y is less than some allowable error factor.
      Parameters:
      x -
      y -
      Returns:
      True if the two doubles are equal to each other (or so close that we don't care that they are different).
    • doubleEquals

      public static boolean doubleEquals(double x, double y)
    • doubleEqualsZero

      public static boolean doubleEqualsZero(double x)
    • doubleEquals

      public static boolean doubleEquals(double x, double y, double tolerance)
      You can't do double1 == double2 because floating point numbers are not exact values. Just make sure that x-y is less than some allowable error factor.
      Parameters:
      x -
      y -
      Returns:
      True if the two doubles are equal to each other (or so close that we don't care that they are different). Also true if both are NaN.
    • doubleEqualsZero

      public static boolean doubleEqualsZero(double x, double tolerance)
    • EQ2

      public static boolean EQ2(double x, double y)
    • doubleEquals2

      public static boolean doubleEquals2(double x, double y)
    • doubleEquals2

      public static boolean doubleEquals2(double x, double y, double tolerance)
    • NE

      public static boolean NE(double x, double y)
      Since logical comparison of double values considering error is effectively a three-value logic, you can't really do !equals when you mean notEquals.
      Parameters:
      x -
      y -
      Returns:
      True if two doubles are apart from each other enough that we consider them different. False if both of them are NaN
    • doubleNotEquals

      public static boolean doubleNotEquals(double x, double y)
    • doubleNotEquals

      public static boolean doubleNotEquals(double x, double y, double tolerance)
    • NE2

      public static boolean NE2(double x, double y)
    • doubleNotEquals2

      public static boolean doubleNotEquals2(double x, double y)
    • doubleNotEquals2

      public static boolean doubleNotEquals2(double x, double y, double tolerance)
    • GT

      public static boolean GT(double x, double y)
      You can't do double1 > double2 because floating point numbers are not exact values. Just make sure that x-y is greater than some allowable error factor for equality
      Parameters:
      x -
      y -
      Returns:
      True if x is greater than y (including error factor for equality).
    • doubleGreater

      public static boolean doubleGreater(double x, double y)
    • doubleGreater

      public static boolean doubleGreater(double x, double y, double tolerance)
    • GE

      public static boolean GE(double x, double y)
    • doubleGreaterEqual

      public static boolean doubleGreaterEqual(double x, double y)
    • doubleGreaterEqual

      public static boolean doubleGreaterEqual(double x, double y, double tolerance)
    • doubleLess

      public static boolean doubleLess(double x, double y, double tolerance)
      You can't do double1 < double2 because floating point numbers are not exact values. Just make sure that y - x is greater than some allowable error factor for equality
      Parameters:
      x -
      y -
      Returns:
      True if x is less than y (including error factor for equality)
    • LT

      public static boolean LT(double x, double y)
    • doubleLess

      public static boolean doubleLess(double x, double y)
    • doubleLessEqual

      public static boolean doubleLessEqual(double x, double y, double tolerance)
    • LE

      public static boolean LE(double x, double y)
    • doubleLessEqual

      public static boolean doubleLessEqual(double x, double y)
    • doubleCompare

      public static int doubleCompare(double d1, double d2)