From: Matthew Fernandez Date: Sun, 19 Sep 2021 21:47:28 +0000 (-0700) Subject: solve2: flip the order of an if-then-else ladder to squash -Wfloat-equal warning X-Git-Tag: 2.49.2~44^2~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09675631f569bfe91aadc4d03de3c01fc2dfa1f8;p=graphviz solve2: flip the order of an if-then-else ladder to squash -Wfloat-equal warning --- diff --git a/lib/pathplan/solvers.c b/lib/pathplan/solvers.c index 2039d1dda..4fd9337a9 100644 --- a/lib/pathplan/solvers.c +++ b/lib/pathplan/solvers.c @@ -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)