mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
bpo-44339: Fix math.pow corner case to comply with IEEE 754 (GH-26606)
Change the behaviour of `math.pow(0.0, -math.inf)` and `math.pow(-0.0, -math.inf)` to return positive infinity instead of raising `ValueError`. This makes `math.pow` consistent with the built-in `pow` (and the `**` operator) for this particular special case, and brings the `math.pow` special-case handling into compliance with IEEE 754.
This commit is contained in:
parent
3ec3ee7d2e
commit
4a42cebf6d
6 changed files with 21 additions and 11 deletions
|
|
@ -2810,8 +2810,6 @@ math_pow_impl(PyObject *module, double x, double y)
|
|||
r = y;
|
||||
else if (y < 0. && fabs(x) < 1.0) {
|
||||
r = -y; /* result is +inf */
|
||||
if (x == 0.) /* 0**-inf: divide-by-zero */
|
||||
errno = EDOM;
|
||||
}
|
||||
else
|
||||
r = 0.;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue