Class FloatComparisons

java.lang.Object
io.deephaven.util.compare.FloatComparisons

public class FloatComparisons extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    compare(float lhs, float rhs)
    Compares two floats according to the following rules: QueryConstants.NULL_FLOAT is less than all other float values (including Float.NEGATIVE_INFINITY) 0.0 and -0.0 are equal Float.NaN (and all other float NaN representations) is equal to Float.NaN and greater than all other float values (including Float.POSITIVE_INFINITY) Otherwise, normal float comparison logic is used
    static boolean
    eq(float lhs, float rhs)
    Compare two floats for equality consistent with compare(float, float); that is compare(lhs, rhs) == 0 ⇒ eq(lhs, rhs) and compare(lhs, rhs) != 0 ⇒ !eq(lhs, rhs).
    static boolean
    geq(float lhs, float rhs)
    Logically equivalent to compare(lhs, rhs) >= 0.
    static boolean
    gt(float lhs, float rhs)
    Logically equivalent to compare(lhs, rhs) > 0.
    static int
    hashCode(float x)
    Returns a hash code for a float value consistent with eq(float, float); that is, eq(x, y) ⇒ hashCode(x) == hashCode(y).
    static boolean
    leq(float lhs, float rhs)
    Logically equivalent to compare(lhs, rhs) <= 0.
    static boolean
    lt(float lhs, float rhs)
    Logically equivalent to compare(lhs, rhs) < 0.

    Methods inherited from class java.lang.Object

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

    • FloatComparisons

      public FloatComparisons()
  • Method Details

    • compare

      public static int compare(float lhs, float rhs)
      Compares two floats according to the following rules:

      Note: this differs from the Java language numerical comparison operators <, <=, ==, >=, > and Float.compare(float, float).

      Parameters:
      lhs - the first value
      rhs - the second value
      Returns:
      the value 0 if lhs is equal to rhs; a value less than 0 if lhs is less than rhs; and a value greater than 0 if lhs is greater than rhs
    • eq

      public static boolean eq(float lhs, float rhs)
      Compare two floats for equality consistent with compare(float, float); that is compare(lhs, rhs) == 0 ⇒ eq(lhs, rhs) and compare(lhs, rhs) != 0 ⇒ !eq(lhs, rhs).

      Logically equivalent to compare(lhs, rhs) == 0.

      Parameters:
      lhs - the first value
      rhs - the second value
      Returns:
      true if the values are equal, false otherwise
    • hashCode

      public static int hashCode(float x)
      Returns a hash code for a float value consistent with eq(float, float); that is, eq(x, y) ⇒ hashCode(x) == hashCode(y).
      Parameters:
      x - the value to hash
      Returns:
      a hash code value for a float value
    • gt

      public static boolean gt(float lhs, float rhs)
      Logically equivalent to compare(lhs, rhs) > 0.
      Parameters:
      lhs - the first value
      rhs - the second value
      Returns:
      true iff lhs is greater than rhs
    • lt

      public static boolean lt(float lhs, float rhs)
      Logically equivalent to compare(lhs, rhs) < 0.
      Parameters:
      lhs - the first value
      rhs - the second value
      Returns:
      true iff lhs is less than rhs
    • geq

      public static boolean geq(float lhs, float rhs)
      Logically equivalent to compare(lhs, rhs) >= 0.
      Parameters:
      lhs - the first value
      rhs - the second value
      Returns:
      true iff lhs is greater than or equal to rhs
    • leq

      public static boolean leq(float lhs, float rhs)
      Logically equivalent to compare(lhs, rhs) <= 0.
      Parameters:
      lhs - the first value
      rhs - the second value
      Returns:
      true iff lhs is less than or equal to rhs