py/modmath: Fix two-argument math function domain check. · MicroPythonNexus/circuitpython@2e4dda3 · GitHub
Skip to content

Commit 2e4dda3

Browse files
committed
py/modmath: Fix two-argument math function domain check.
Prior to this fix, pow(1.5, inf) and pow(0.5, -inf) (among other things) would incorrectly raise a ValueError, because the result is inf with the first argument being finite. This commit fixes this by allowing the result to be infinite if the first or second (or both) argument is infinite. This fix doesn't affect the other three math functions that have two arguments: - atan2 never returns inf, so always fails isinf(ans) - copysign returns inf only if the first argument x is inf, so will never reach the isinf(y) check - fmod never returns inf, so always fails isinf(ans) Signed-off-by: Damien George <damien@micropython.org>
1 parent 5327cd1 commit 2e4dda3

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

py/modmath.c

Lines changed: 1 addition & 1 deletion

tests/float/math_domain.py

Lines changed: 20 additions & 1 deletion

0 commit comments

Comments
 (0)