Skip to content

Commit c70bf9e

Browse files
authored
Fix DD equals and compareTo (#1186)
1 parent f6db30d commit c70bf9e

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

  • modules/core/src/main/java/org/locationtech/jts/math

modules/core/src/main/java/org/locationtech/jts/math/DD.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
*
9292
*/
9393
public strictfp final class DD
94-
implements Serializable, Comparable, Cloneable
94+
implements Serializable, Comparable<DD>, Cloneable
9595
{
9696
/**
9797
* The value nearest to the constant Pi.
@@ -985,9 +985,12 @@ public boolean isPositive()
985985
* @param y a DoubleDouble value
986986
* @return true if this value = y
987987
*/
988-
public boolean equals(DD y)
988+
public boolean equals(Object o)
989989
{
990-
return hi == y.hi && lo == y.lo;
990+
if (this == o) return true;
991+
if (o == null || getClass() != o.getClass()) return false;
992+
DD dd = (DD) o;
993+
return hi == dd.hi && lo == dd.lo;
991994
}
992995

993996
/**
@@ -1030,13 +1033,12 @@ public boolean le(DD y)
10301033
/**
10311034
* Compares two DoubleDouble objects numerically.
10321035
*
1036+
* @param other a DD value to compare to
10331037
* @return -1,0 or 1 depending on whether this value is less than, equal to
10341038
* or greater than the value of <tt>o</tt>
10351039
*/
1036-
public int compareTo(Object o)
1040+
public int compareTo(DD other)
10371041
{
1038-
DD other = (DD) o;
1039-
10401042
if (hi < other.hi) return -1;
10411043
if (hi > other.hi) return 1;
10421044
if (lo < other.lo) return -1;

0 commit comments

Comments
 (0)