[PATCH] Fixed misuse of x !=/== Double.NaN

Wald Commits scm-commit at wald.intevation.org
Fri Sep 13 17:42:14 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1379086929 -7200
# Node ID a9ff696c2d18acd997f94bc88d28c505940d3b49
# Parent  56891f61e534b4e2ce14e6bb045a7db48a979cc0
Fixed misuse of x !=/== Double.NaN

diff -r 56891f61e534 -r a9ff696c2d18 artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java	Fri Sep 13 16:10:10 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java	Fri Sep 13 17:42:09 2013 +0200
@@ -977,7 +977,7 @@
 
         for (int col = 0; col < columns.length; col++) {
             qs[col] = columns[col].getQRangeTree().findQ(km);
-            if (startRow.km == km && startRow.ws[col] != Double.NaN) {
+            if (startRow.km == km && !Double.isNaN(startRow.ws[col])) {
                 // Great. W is defined at km.
                 ws[col] = startRow.ws[col];
                 continue;
diff -r 56891f61e534 -r a9ff696c2d18 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFraction.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFraction.java	Fri Sep 13 16:10:10 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFraction.java	Fri Sep 13 17:42:09 2013 +0200
@@ -193,31 +193,31 @@
     /** Returns true if all fraction values except SuspSediment are unset. */
     public boolean hasOnlySuspValues() {
         return
-            getSuspSediment() != Double.NaN &&
-            getCoarse() == Double.NaN &&
-            getFineMiddle() == Double.NaN &&
-            getSand() == Double.NaN &&
-            getSuspSand() == Double.NaN;
+            !Double.isNaN(getSuspSediment()) &&
+            Double.isNaN(getCoarse()) &&
+            Double.isNaN(getFineMiddle()) &&
+            Double.isNaN(getSand()) &&
+            Double.isNaN(getSuspSand());
     }
 
     /** Returns true if all fraction values except SuspSediment are set. */
     public boolean hasButSuspValues() {
         return
-            getSuspSediment() == Double.NaN &&
-            getCoarse() != Double.NaN &&
-            getFineMiddle() != Double.NaN &&
-            getSand() != Double.NaN &&
-            getSuspSand() != Double.NaN;
+            Double.isNaN(getSuspSediment()) &&
+            !Double.isNaN(getCoarse()) &&
+            !Double.isNaN(getFineMiddle()) &&
+            !Double.isNaN(getSand()) &&
+            !Double.isNaN(getSuspSand());
     }
 
     /** Returns true if all fraction needed for total calculation are set. */
     public boolean isComplete() {
         return
-            getCoarse() != Double.NaN &&
-            getFineMiddle() != Double.NaN &&
-            getSand() != Double.NaN &&
-            getSuspSand() != Double.NaN &&
-            getSuspSediment() != Double.NaN;
+            !Double.isNaN(getCoarse()) &&
+            !Double.isNaN(getFineMiddle()) &&
+            !Double.isNaN(getSand()) &&
+            !Double.isNaN(getSuspSand()) &&
+            !Double.isNaN(getSuspSediment());
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :


More information about the Dive4elements-commits mailing list