Package io.deephaven.util.compare
Class FloatComparisons
java.lang.Object
io.deephaven.util.compare.FloatComparisons
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompare(float lhs, float rhs) Compares two floats according to the following rules:QueryConstants.NULL_FLOATis less than all otherfloatvalues (includingFloat.NEGATIVE_INFINITY)0.0and-0.0are equalFloat.NaN(and all other floatNaNrepresentations) is equal toFloat.NaNand greater than all otherfloatvalues (includingFloat.POSITIVE_INFINITY) Otherwise, normalfloatcomparison logic is usedstatic booleaneq(float lhs, float rhs) Compare two floats for equality consistent withcompare(float, float); that iscompare(lhs, rhs) == 0 ⇒ eq(lhs, rhs)andcompare(lhs, rhs) != 0 ⇒ !eq(lhs, rhs).static booleangeq(float lhs, float rhs) Logically equivalent tocompare(lhs, rhs) >= 0.static booleangt(float lhs, float rhs) Logically equivalent tocompare(lhs, rhs) > 0.static inthashCode(float x) Returns a hash code for afloatvalue consistent witheq(float, float); that is,eq(x, y) ⇒ hashCode(x) == hashCode(y).static booleanleq(float lhs, float rhs) Logically equivalent tocompare(lhs, rhs) <= 0.static booleanlt(float lhs, float rhs) Logically equivalent tocompare(lhs, rhs) < 0.
-
Constructor Details
-
FloatComparisons
public FloatComparisons()
-
-
Method Details
-
compare
public static int compare(float lhs, float rhs) Compares two floats according to the following rules:QueryConstants.NULL_FLOATis less than all otherfloatvalues (includingFloat.NEGATIVE_INFINITY)0.0and-0.0are equalFloat.NaN(and all other floatNaNrepresentations) is equal toFloat.NaNand greater than all otherfloatvalues (includingFloat.POSITIVE_INFINITY)- Otherwise, normal
floatcomparison logic is used
Note: this differs from the Java language numerical comparison operators
<, <=, ==, >=, >andFloat.compare(float, float).- Parameters:
lhs- the first valuerhs- the second value- Returns:
- the value
0iflhsis equal torhs; a value less than0iflhsis less thanrhs; and a value greater than0iflhsis greater thanrhs
-
eq
public static boolean eq(float lhs, float rhs) Compare two floats for equality consistent withcompare(float, float); that iscompare(lhs, rhs) == 0 ⇒ eq(lhs, rhs)andcompare(lhs, rhs) != 0 ⇒ !eq(lhs, rhs).Logically equivalent to
compare(lhs, rhs) == 0.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueif the values are equal,falseotherwise
-
hashCode
public static int hashCode(float x) Returns a hash code for afloatvalue consistent witheq(float, float); that is,eq(x, y) ⇒ hashCode(x) == hashCode(y).- Parameters:
x- the value to hash- Returns:
- a hash code value for a
floatvalue
-
gt
public static boolean gt(float lhs, float rhs) Logically equivalent tocompare(lhs, rhs) > 0.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueifflhsis greater thanrhs
-
lt
public static boolean lt(float lhs, float rhs) Logically equivalent tocompare(lhs, rhs) < 0.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueifflhsis less thanrhs
-
geq
public static boolean geq(float lhs, float rhs) Logically equivalent tocompare(lhs, rhs) >= 0.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueifflhsis greater than or equal torhs
-
leq
public static boolean leq(float lhs, float rhs) Logically equivalent tocompare(lhs, rhs) <= 0.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueifflhsis less than or equal torhs
-