Prevent invalid invinite solutions in Numerical.solveQuadratic()

Closes #708
This commit is contained in:
Jürg Lehni 2015-06-16 12:30:25 +02:00
parent e3f04478d9
commit ce41447793

View file

@ -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);