From ce4144779302751ded706304e0db110acb085d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 16 Jun 2015 12:30:25 +0200 Subject: [PATCH] Prevent invalid invinite solutions in Numerical.solveQuadratic() Closes #708 --- src/util/Numerical.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/Numerical.js b/src/util/Numerical.js index da7e1b80..0796429a 100644 --- a/src/util/Numerical.js +++ b/src/util/Numerical.js @@ -176,12 +176,12 @@ var Numerical = new function() { B = b, D; b /= 2; - D = b * b - a * c; // Discriminant + D = b * b - a * c; // Discriminant /* * If the discriminant is very small, we can try to pre-condition * the coefficients, so that we may get better accuracy */ - if (abs(D) < MACHINE_EPSILON) { + if (D !== 0 && abs(D) < MACHINE_EPSILON) { // If the geometric mean of the coefficients is small enough var pow = Math.pow, gmC = pow(abs(a*b*c), 1/3);