MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / compare

Method compare

CodenameOne/src/com/codename1/util/MathUtil.java:1450–1465  ·  view source on GitHub ↗
(float f1, float f2)

Source from the content-addressed store, hash-verified

1448 /// `f2`.
1449 ///
1450 public static int compare(float f1, float f2) {
1451 if (f1 < f2) {
1452 return -1; // Neither val is NaN, thisVal is smaller
1453 }
1454 if (f1 > f2) {
1455 return 1; // Neither val is NaN, thisVal is larger
1456 }
1457
1458 // Cannot use floatToRawIntBits because of possibility of NaNs.
1459 int thisBits = Float.floatToIntBits(f1);
1460 int anotherBits = Float.floatToIntBits(f2);
1461
1462 return (thisBits == anotherBits ? 0 : // Values are equal
1463 (thisBits < anotherBits ? -1 : // (-0.0, 0.0) or (!NaN, NaN)
1464 1)); // (0.0, -0.0) or (NaN, !NaN)
1465 }
1466
1467 /// Compares the two specified `double` values. The sign
1468 /// of the integer value returned is the same as that of the

Callers 1

equalsLatLngMethod · 0.95

Calls 2

floatToIntBitsMethod · 0.95
doubleToLongBitsMethod · 0.95

Tested by

no test coverage detected