Break loop whem `sum==0` to avoid zero division; ref #4345

parent a26856f8
......@@ -120,6 +120,7 @@ erf(double x)
term *= xsqr/j;
sum += term/(2*j+1);
++j;
if (sum == 0) break;
} while (fabs(term/sum) > DBL_EPSILON);
return two_sqrtpi*sum;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment