Mercurial > dive4elements > river
changeset 5151:240ff7aeb6de
DoubleUtil: Use tolerance when comparing doubles in explode(). Fixes flys/issue1132.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 01 Mar 2013 10:04:57 +0100 (2013-03-01) |
parents | 345f3bba6f15 |
children | b26465581abf |
files | flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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); }