diff --git a/venn.js b/venn.js index 89f840c..5de0f1b 100644 --- a/venn.js +++ b/venn.js @@ -238,13 +238,13 @@ fB = f(b), delta = b - a; + if (Math.abs(fA) < tolerance) return a; + if (Math.abs(fB) < tolerance) return b; + if (fA * fB > 0) { throw "Initial bisect points must have opposite signs"; } - if (fA === 0) return a; - if (fB === 0) return b; - for (var i = 0; i < maxIterations; ++i) { delta /= 2; var mid = a + delta,