Mercurial > cpython-lru_cache-weakref
diff Objects/complexobject.c @ 35580:f4c2c61cb560 2.4
backport patch [ 1118729 ] Error in representation of complex numbers(again)
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Fri, 16 Sep 2005 06:42:32 +0000 |
| parents | 46fa0e20cbcf |
| children | 45ac9ce0bb15 9541369b0dca |
line wrap: on
line diff
--- a/Objects/complexobject.c Thu Sep 15 18:07:11 2005 +0000 +++ b/Objects/complexobject.c Fri Sep 16 06:42:32 2005 +0000 @@ -279,15 +279,12 @@ strncat(buf, "j", bufsz); } else { char re[64], im[64]; - char *fmt; + /* Format imaginary part with sign, real part without */ PyOS_snprintf(format, 32, "%%.%ig", precision); PyOS_ascii_formatd(re, 64, format, v->cval.real); + PyOS_snprintf(format, 32, "%%+.%ig", precision); PyOS_ascii_formatd(im, 64, format, v->cval.imag); - if (v->cval.imag < 0.) - fmt = "(%s%sj)"; - else - fmt = "(%s+%sj)"; - PyOS_snprintf(buf, bufsz, fmt, re, im); + PyOS_snprintf(buf, bufsz, "(%s%sj)", re, im); } }
