Skip to content

Commit 50203a6

Browse files
committed
Return +-Py_HUGE_VAL for tgamma(+-0) instead of risking FP exceptions by computing 1.0 / 0.0.
1 parent 36f27c9 commit 50203a6

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Modules/mathmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ m_tgamma(double x)
239239
}
240240
if (x == 0.0) {
241241
errno = EDOM;
242-
return 1.0/x; /* tgamma(+-0.0) = +-inf, divide-by-zero */
242+
/* tgamma(+-0.0) = +-inf, divide-by-zero */
243+
return copysign(Py_HUGE_VAL, x);
243244
}
244245

245246
/* integer arguments */

0 commit comments

Comments
 (0)