summaryrefslogtreecommitdiffstatshomepage
path: root/py/modmath.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/modmath.c')
-rw-r--r--py/modmath.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/modmath.c b/py/modmath.c
index b792d8581d..919a8ccd9d 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -161,6 +161,11 @@ MATH_FUN_2(atan2, atan2)
MATH_FUN_1_TO_INT(ceil, ceil)
// copysign(x, y)
static mp_float_t MICROPY_FLOAT_C_FUN(copysign_func)(mp_float_t x, mp_float_t y) {
+ #if MICROPY_PY_MATH_COPYSIGN_FIX_NAN
+ if (isnan(y)) {
+ y = 0.0;
+ }
+ #endif
return MICROPY_FLOAT_C_FUN(copysign)(x, y);
}
MATH_FUN_2(copysign, copysign_func)