public static boolean approxEquals(final double a,final double b,final double tolerance){
  if (Double.isNaN(a) || Double.isNaN(b)) {
    return false;
  }
  if (a == b) {
    return true;
  }
  if (Double.isInfinite(a) || Double.isInfinite(b)) {
    return false;
  }
  if (a >= (b - tolerance) && a <= (b + tolerance)) {
    return true;
  }
  return false;
}

public static boolean approxEquals ( final double a , final double b , final double tolerance ) { if ( Double . isNaN ( a ) || Double . isNaN ( b ) ) { return false ; } if ( a == b ) { return true ; } if ( Double . isInfinite ( a ) || Double . isInfinite ( b ) ) { return false ; } if ( a >= ( b - tolerance ) && a <= ( b + tolerance ) ) { return true ; } return false ; }
check if two doubles are equal to within specified tolerance .
