Commit 709955b6 by stijn Committed by Damien George

### py: Fix printing of complex number when imaginary part is nan

parent 1db3577b
 ... ... @@ -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); ... ...
 ... ... @@ -43,6 +43,11 @@ print("%.5g" % abs(1j + 2)) # float on lhs should delegate to complex print(1.2 + 3j) # check printing of inf/nan print(float('nan') * 1j) print(float('inf') * (1 + 1j)) print(float('-inf') * (1 + 1j)) # convert bignum to complex on rhs ans = 1j + (1 << 70); print("%.5g %.5g" % (ans.real, ans.imag)) ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!