org.deri.iris.utils
Interface IFloatingPointComparator

All Known Implementing Classes:
StandardFloatingPointComparator, StrictFloatingPointComparator

public interface IFloatingPointComparator

A floating-point number comparator. Classes that implement this interface can either perform strict comparison or allow for round-off errors.


Method Summary
 int compare(double a, double b)
          An error-safe comparison in the java style.
 boolean equals(double a, double b)
          Test two double values for equality.
 boolean greater(double a, double b)
          Floating-point error safe comparison.
 boolean greaterOrEquals(double a, double b)
          Floating-point error safe comparison.
 boolean isIntValue(double value)
          Indicates whether a double value contains an integer or a number very, very close to an integer.
 boolean less(double a, double b)
          Floating-point error safe comparison.
 boolean lessOrEquals(double a, double b)
          Floating-point error safe comparison.
 boolean notEquals(double a, double b)
          Floating-point error safe comparison.
 

Method Detail

compare

int compare(double a,
            double b)
An error-safe comparison in the java style.

Parameters:
a - A double value
b - A double value
Returns:
-1 if a is significantly less than b, +1 if a is significantly greater than b, 0 if a and b are close enough.

less

boolean less(double a,
             double b)
Floating-point error safe comparison.

Parameters:
a - A double value
b - A double value
Returns:
true If a is less than b.

greater

boolean greater(double a,
                double b)
Floating-point error safe comparison.

Parameters:
a - A double value
b - A double value
Returns:
true If a is greater than b.

greaterOrEquals

boolean greaterOrEquals(double a,
                        double b)
Floating-point error safe comparison.

Parameters:
a - A double value
b - A double value
Returns:
true If a is greater than or close enough to be equal to b.

lessOrEquals

boolean lessOrEquals(double a,
                     double b)
Floating-point error safe comparison.

Parameters:
a - A double value
b - A double value
Returns:
true If a is less than or close enough to be equal to b.

equals

boolean equals(double a,
               double b)
Test two double values for equality.

Parameters:
a - A double value
b - A double value
Returns:
true If a and b are considered equal.

notEquals

boolean notEquals(double a,
                  double b)
Floating-point error safe comparison.

Parameters:
a -
b -
Returns:
true If a and b are significantly different.

isIntValue

boolean isIntValue(double value)
Indicates whether a double value contains an integer or a number very, very close to an integer.

Parameters:
value - The value to test
Returns:
true If value holds an integer.