public static int fuzzyCompare(double a,double b,double tolerance){
  if (tolerance < 0.0)   throw new IllegalArgumentException("The tolerance may not be negative");
  double difference=a - b;
  return (Math.abs(difference) <= tolerance ? 0 : (difference > 0 ? 1 : -1));
}

public static int fuzzyCompare ( double a , double b , double tolerance ) { if ( tolerance < 0.0 ) throw new IllegalArgumentException ( "The tolerance may not be negative" ) ; double difference = a - b ; return ( Math . abs ( difference ) <= tolerance ? 0 : ( difference > 0 ? 1 : - 1 ) ) ; }
compares two floating point numbers with a tolerance .
