Skip to content

Commit 33c8223

Browse files
author
birkenfeld
committed
patch [ 1118729 ] Error in representation of complex numbers(again)
git-svn-id: http://svn.python.org/projects/python/trunk@39551 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 67c7f35 commit 33c8223

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

Objects/complexobject.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,12 @@ complex_to_buf(char *buf, int bufsz, PyComplexObject *v, int precision)
279279
strncat(buf, "j", bufsz);
280280
} else {
281281
char re[64], im[64];
282-
char *fmt;
282+
/* Format imaginary part with sign, real part without */
283283
PyOS_snprintf(format, 32, "%%.%ig", precision);
284284
PyOS_ascii_formatd(re, 64, format, v->cval.real);
285+
PyOS_snprintf(format, 32, "%%+.%ig", precision);
285286
PyOS_ascii_formatd(im, 64, format, v->cval.imag);
286-
if (v->cval.imag < 0.)
287-
fmt = "(%s%sj)";
288-
else
289-
fmt = "(%s+%sj)";
290-
PyOS_snprintf(buf, bufsz, fmt, re, im);
287+
PyOS_snprintf(buf, bufsz, "(%s%sj)", re, im);
291288
}
292289
}
293290

0 commit comments

Comments
 (0)