]> granicus.if.org Git - graphviz/commitdiff
solve2: flip the order of an if-then-else ladder to squash -Wfloat-equal warning
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 19 Sep 2021 21:47:28 +0000 (14:47 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 25 Sep 2021 17:22:20 +0000 (10:22 -0700)
lib/pathplan/solvers.c

index 2039d1ddac2cb03322d9d6336302cbb8a67ce52c..4fd9337a9762afcb0c37cdca58c49668a8e81336 100644 (file)
@@ -74,16 +74,15 @@ int solve2(double *coeff, double *roots)
     c_over_a = c / a;
 
     disc = b_over_2a * b_over_2a - c_over_a;
-    if (disc < 0)
+    if (disc < 0) {
        return 0;
-    else if (disc == 0) {
-       roots[0] = -b_over_2a;
-       return 1;
-    } else {
+    } else if (disc > 0) {
        roots[0] = -b_over_2a + sqrt(disc);
        roots[1] = -2 * b_over_2a - roots[0];
        return 2;
     }
+    roots[0] = -b_over_2a;
+    return 1;
 }
 
 int solve1(double *coeff, double *roots)