MCPcopy Create free account
hub / github.com/antlr/codebuff / fuzzyCompare

Method fuzzyCompare

output/java_guava/1.4.18/DoubleMath.java:379–389  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

fuzzyEqualsMethod · 0.95
compareMethod · 0.95

Tested by

no test coverage detected