Alex Herbert created NUMBERS-185:
------------------------------------
Summary: Precision.compareTo with ulps cannot be used for sorting
Key: NUMBERS-185
URL: https://issues.apache.org/jira/browse/NUMBERS-185
Project: Commons Numbers
Issue Type: Bug
Components: core
Affects Versions: 1.0
Reporter: Alex Herbert
Fix For: 1.1
The Precision.compareTo class was fixed in NUMBERS-154 to allow correct
handling of NaN values. This fixed was applied to the compareTo with a delta
but not compareTo using a max ULP argument.
This can be fixed by using Double.compare (as is done in compareTo(double,
double, double):
{code:java}
public static int compareTo(final double x, final double y, final int
maxUlps) {
if (equals(x, y, maxUlps)) {
return 0;
} else if (x < y) {
return -1;
} else if (x > y) {
return 1;
}
// NaN input.
return Double.compare(x, y);
} {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)