[Dive4elements-commits] [PATCH 2 of 2] DoubleUtil: Use tolerance when comparing doubles in explode(). Fixes flys/issue1132

Wald Commits scm-commit at wald.intevation.org
Fri Mar 1 09:58:08 CET 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1362128697 -3600
# Node ID 240ff7aeb6de8c9058784ed80b196ae9ab9638e5
# Parent  345f3bba6f15e8762bb7418087fc94abbf46f17a
DoubleUtil: Use tolerance when comparing doubles in explode(). Fixes flys/issue1132.

diff -r 345f3bba6f15 -r 240ff7aeb6de flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java	Fri Mar 01 09:51:43 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java	Fri Mar 01 10:04:57 2013 +0100
@@ -16,6 +16,9 @@
 
     public static final double DEFAULT_STEP_PRECISION = 1e6;
 
+    /** EPSILON for comparison of double precision values. */
+    public static final double EPSILON = 1e-4;
+
     private DoubleUtil() {
     }
 
@@ -60,7 +63,7 @@
         double max = Math.max(from, to);
 
         for (int idx = 0; idx < num; idx++) {
-            if (lower > max) {
+            if (lower - max > EPSILON) {
                 return Arrays.copyOfRange(values, 0, idx);
             }
 


More information about the Dive4elements-commits mailing list