diff options
Diffstat (limited to 'py/objcomplex.c')
-rw-r--r-- | py/objcomplex.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objcomplex.c b/py/objcomplex.c index 12f10ec10b..8a424f7f26 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -59,7 +59,7 @@ STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_ } else { mp_format_float(o->real, buf, sizeof(buf), 'g', 7, '\0'); mp_printf(print, "(%s", buf); - if (o->imag >= 0) { + if (o->imag >= 0 || isnan(o->imag)) { mp_print_str(print, "+"); } mp_format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0'); @@ -73,7 +73,7 @@ STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_ } else { sprintf(buf, "%.16g", (double)o->real); mp_printf(print, "(%s", buf); - if (o->imag >= 0) { + if (o->imag >= 0 || isnan(o->imag)) { mp_print_str(print, "+"); } sprintf(buf, "%.16g", (double)o->imag); |