public interface FloatComparator
float values.
This is a @FunctionalInterface even though it isn't declared as one,
so that it can be used in Java 6+.
| Modifier and Type | Method and Description |
|---|---|
int |
compare(float f1,
float f2)
Compares
f1 and f2. |
int compare(float f1,
float f2)
f1 and f2. Returns a negative value to indicate
that f1 < f2, 0 to indicate that f1 == f2, and a positive
value to indicate that f1 > f2.
Implementations of this method must maintain the following invariants:
s(compare(x, y)) == -s(compare(y, x))
s(compare(x, y)) == s(compare(y, z)) →
s(compare(x, y)) == s(compare(x, z)) (transitivity)
compare(x, y) == 0 →
s(compare(x, z)) == s(compare(y, z)) ∀ z
where s(x) is defined as follows:
x < 0: -1
x == 0: 0
x > 0: 1
Float.NEGATIVE_INFINITY, and Float.POSITIVE_INFINITY
values. See Float.compareTo(Float) for a valid example.f1 - the first float to comparef2 - the second float to comparef1 is less than, equal to, or greater than f2,
respectivelyCopyright © 2021. All rights reserved.