]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Future-proof helper function with zero handling. (GH-107798)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Wed, 9 Aug 2023 07:44:43 +0000 (08:44 +0100)
committerGitHub <noreply@github.com>
Wed, 9 Aug 2023 07:44:43 +0000 (08:44 +0100)
Lib/statistics.py

index 066669d25ddb1264df30b01555c79e2d73fdf628..93c44f1f13fab73514edbc947c8d1d46cb088235 100644 (file)
@@ -1009,6 +1009,8 @@ def _sqrtprod(x: float, y: float) -> float:
     # Square root differential correction:
     # https://www.wolframalpha.com/input/?i=Maclaurin+series+sqrt%28h**2+%2B+x%29+at+x%3D0
     h = sqrt(x * y)
+    if not h:
+        return 0.0
     x = sumprod((x, h), (y, -h))
     return h + x / (2.0 * h)