(float f1, float f2)
| 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 |
no test coverage detected