Index: trunk/src/org/openstreetmap/josm/tools/Geometry.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 15035)
+++ trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 15036)
@@ -1156,9 +1156,10 @@
             double distance = getDistance(osm, primitive);
             if (Double.isNaN(distance)) continue;
-            if (distance < lowestDistance) {
+            int comp = Double.compare(distance, lowestDistance);
+            if (comp < 0) {
                 closest.clear();
                 lowestDistance = distance;
                 closest.add(primitive);
-            } else if (distance == lowestDistance) {
+            } else if (comp == 0) {
                 closest.add(primitive);
             }
@@ -1219,9 +1220,10 @@
             double distance = getDistance(osm, primitive);
             if (Double.isNaN(distance)) continue;
-            if (distance > furthestDistance) {
+            int comp = Double.compare(distance, furthestDistance);
+            if (comp > 0) {
                 furthest.clear();
                 furthestDistance = distance;
                 furthest.add(primitive);
-            } else if (distance == furthestDistance) {
+            } else if (comp == 0) {
                 furthest.add(primitive);
             }
