summaryrefslogtreecommitdiffstatshomepage
path: root/py/objcomplex.c
diff options
context:
space:
mode:
authorstijn <stinos@zoho.com>2015-05-13 21:35:58 +0200
committerDamien George <damien.p.george@gmail.com>2015-05-13 23:10:15 +0100
commit709955b601a0b7de7a85e91d97846660979904a7 (patch)
tree5231c4afdc5879dbf52bd489d0861175a468493c /py/objcomplex.c
parent1db3577bcb7ff6016c7a938e502ba49f7e52419f (diff)
downloadmicropython-709955b601a0b7de7a85e91d97846660979904a7.tar.gz
micropython-709955b601a0b7de7a85e91d97846660979904a7.zip
py: Fix printing of complex number when imaginary part is nan
Diffstat (limited to 'py/objcomplex.c')
-rw-r--r--py/objcomplex.c4
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);