|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.deri.iris.utils.StandardFloatingPointComparator
public class StandardFloatingPointComparator
Utility class for floating point comparison. This class allows for round-off errors by using only the specified most significant bits of the operands, after allowing for scale.
| Field Summary | |
|---|---|
static int |
BINARY_DIGITS_OF_PRECISION_DOUBLE
ieee754 (double) uses 52 bits to represent the significand. |
static int |
BINARY_DIGITS_OF_PRECISION_FLOAT
ieee754 (float) uses 23 bits to represent the significand. |
static int |
LEAST_SIGNIFICANT_BINARY_DIGITS_TO_IGNORE_DOUBLE
The standard number of least significant bits to ignore for a double type. |
static int |
LEAST_SIGNIFICANT_BINARY_DIGITS_TO_IGNORE_FLOAT
The standard number of least significant bits to ignore for a float type. |
double |
MAX_DIFFERENCE_FROM_ONE
This number is used to find the maximum difference between two numbers that can be considered logically the same. |
static IFloatingPointComparator |
mStandardDoubleInstance
The standard comparator for double type. |
static IFloatingPointComparator |
mStandardFloatInstance
The standard comparator for float types. |
| Constructor Summary | |
|---|---|
StandardFloatingPointComparator(int numberOfSignificantBits)
Constructor. |
|
| 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. |
static IFloatingPointComparator |
getDouble()
Singleton-like method to get the standard setup for dealing with double type. |
static IFloatingPointComparator |
getFloat()
Singleton-like method to get the standard setup for dealing with float type. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final double MAX_DIFFERENCE_FROM_ONE
public static final int BINARY_DIGITS_OF_PRECISION_DOUBLE
public static final int BINARY_DIGITS_OF_PRECISION_FLOAT
public static final int LEAST_SIGNIFICANT_BINARY_DIGITS_TO_IGNORE_DOUBLE
public static final int LEAST_SIGNIFICANT_BINARY_DIGITS_TO_IGNORE_FLOAT
public static final IFloatingPointComparator mStandardDoubleInstance
public static final IFloatingPointComparator mStandardFloatInstance
| Constructor Detail |
|---|
public StandardFloatingPointComparator(int numberOfSignificantBits)
numberOfSignificantBits - The number of significant bits in the significand to use when
comparing values. If a non-standard setup is used then it is up to the user to set this
value correctly.| Method Detail |
|---|
public static IFloatingPointComparator getDouble()
public static IFloatingPointComparator getFloat()
public int compare(double a,
double b)
IFloatingPointComparator
compare in interface IFloatingPointComparatora - A double valueb - A double value
public boolean less(double a,
double b)
IFloatingPointComparator
less in interface IFloatingPointComparatora - A double valueb - A double value
public boolean greater(double a,
double b)
IFloatingPointComparator
greater in interface IFloatingPointComparatora - A double valueb - A double value
public boolean greaterOrEquals(double a,
double b)
IFloatingPointComparator
greaterOrEquals in interface IFloatingPointComparatora - A double valueb - A double value
public boolean lessOrEquals(double a,
double b)
IFloatingPointComparator
lessOrEquals in interface IFloatingPointComparatora - A double valueb - A double value
public boolean equals(double a,
double b)
equals in interface IFloatingPointComparatora - A double valueb - A double value
public boolean notEquals(double a,
double b)
IFloatingPointComparator
notEquals in interface IFloatingPointComparatorpublic boolean isIntValue(double value)
IFloatingPointComparator
isIntValue in interface IFloatingPointComparatorvalue - The value to test
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||