compareStatic static method

int compareStatic(
  1. double a,
  2. double b
)

Compare two doubles, allowing for NaN values. NaN is treated as being less than any valid number.

@param a a double @param b a double @return -1, 0, or 1 depending on whether a is less than, equal to or greater than b

Implementation

static int compareStatic(double a, double b) {
  if (a < b) return -1;
  if (a > b) return 1;

  if (a.isNaN) {
    if (b.isNaN) return 0;
    return -1;
  }

  if (b.isNaN) return 1;
  return 0;
}