don't use substraction for comparison if datatypes can overflow

This commit is contained in:
Simon Willnauer 2013-02-07 12:06:56 +01:00
parent f97021b165
commit 033d6e4306

View File

@ -105,7 +105,13 @@ public class GeoDistanceComparator extends FieldComparator<Double> {
} else {
distance1 = fixedSourceDistance.calculate(geoPoint.lat(), geoPoint.lon());
}
return (int) (distance1 - distance2);
if (distance1 < distance2) {
return -1;
} else if (distance1 == distance2) {
return 0;
} else {
return 1;
}
}
@Override