Skip to content

Commit 48a5715

Browse files
committed
Use Double.compare(d1,d2) instead of standard comparison operators to handle Double.NaN and 0.0d != -0.0d
1 parent 2975c93 commit 48a5715

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/java/tdg09/Utils.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,7 @@ public int compare(T o1, T o2) {
6767
double d1 = f.getDouble(o1);
6868
double d2 = f.getDouble(o2);
6969

70-
if (d1 < d2) {
71-
return -1;
72-
} else if (d1 == d2) {
73-
return 0;
74-
} else {
75-
return 1;
76-
}
70+
return Double.compare(d1, d2);
7771

7872
} catch (Exception e) {
7973
throw new RuntimeException(e);

0 commit comments

Comments
 (0)