public static boolean compareDoubles(double a,double b){
  if (Double.isNaN(a) && Double.isNaN(b))   return true;
  if (!Double.isInfinite(a) && !Double.isInfinite(b))   return Math.abs(a - b) <= EPSILON;
  return a == b;
}

public static boolean compareDoubles ( double a , double b ) { if ( Double . isNaN ( a ) && Double . isNaN ( b ) ) return true ; if ( ! Double . isInfinite ( a ) && ! Double . isInfinite ( b ) ) return Math . abs ( a - b ) <= EPSILON ; return a == b ; }
compares two doubles for equality .
