Compares a and b "fuzzily," with a tolerance for nearly-equal values. This method is equivalent to fuzzyEquals(a, b, tolerance) ? 0 : Double.compare(a, b). In particular, like Double#compare(double, double), it treats all NaN values as equal and greater than all o
(double a, double b, double tolerance)
| 377 | |
| 378 | |
| 379 | public static int fuzzyCompare(double a, double b, double tolerance) { |
| 380 | if (fuzzyEquals(a, b, tolerance)) { |
| 381 | return 0; |
| 382 | } else if (a < b) { |
| 383 | return -1; |
| 384 | } else if (a > b) { |
| 385 | return 1; |
| 386 | } else { |
| 387 | return Booleans.compare(Double.isNaN(a), Double.isNaN(b)); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | /** |
| 392 | * Returns the <a href="http://en.wikipedia.org/wiki/Arithmetic_mean">arithmetic mean</a> of |
nothing calls this directly
no test coverage detected