Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2fb484e

Browse files
authored
Future-proof helper function with zero handling. (GH-107798)
1 parent 34cafd3 commit 2fb484e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Lib/statistics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,8 @@ def _sqrtprod(x: float, y: float) -> float:
10091009
# Square root differential correction:
10101010
# https://www.wolframalpha.com/input/?i=Maclaurin+series+sqrt%28h**2+%2B+x%29+at+x%3D0
10111011
h = sqrt(x * y)
1012+
if not h:
1013+
return 0.0
10121014
x = sumprod((x, h), (y, -h))
10131015
return h + x / (2.0 * h)
10141016

0 commit comments

Comments
 (0)