]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 2 Dec 2024 14:42:02 +0000 (15:42 +0100)
committerGitHub <noreply@github.com>
Mon, 2 Dec 2024 14:42:02 +0000 (15:42 +0100)
commitf41d8d89e79d634895868656f50a0e16e339f9d6
treeaa7279efd3f40e877c54fb2bf9099082ccdb1c87
parent511c588f5d5b9f8eb0e836652ca3ecf86518401e
[3.13] gh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211) (#127216)

Note, that transformed expression is not an equivalent for original one (1/exp(-x) != exp(x) in general for floating-point numbers). Though, the difference seems to be ~1ULP for good libm implementations.

It's more interesting why division was used from beginning. Closest algorithm I've found (no error checks, of course;)) - it's Algorithm 190 from ACM: https://dl.acm.org/doi/10.1145/366663.366679. It uses subtraction in the exponent.

(cherry picked from commit f7bb658124aba74be4c13f498bf46cfded710ef9)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Lib/test/test_complex.py
Misc/NEWS.d/next/Core_and_Builtins/2024-11-24-07-01-28.gh-issue-113841.WFg-Bu.rst [new file with mode: 0644]
Objects/complexobject.c