summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-09-16 06:42:26 (GMT)
committerGeorg Brandl <georg@python.org>2005-09-16 06:42:26 (GMT)
commitc404ff2f2d711fdb0f9adf096b4ffa01891fd3d4 (patch)
tree52fa13626032d4a29afce52452856b0014760766
parentbd9c3f702825a82e0ac8fbcc2cdc40364de6747f (diff)
downloadcpython-c404ff2f2d711fdb0f9adf096b4ffa01891fd3d4.zip
cpython-c404ff2f2d711fdb0f9adf096b4ffa01891fd3d4.tar.gz
cpython-c404ff2f2d711fdb0f9adf096b4ffa01891fd3d4.tar.bz2
patch [ 1118729 ] Error in representation of complex numbers(again)
-rw-r--r--Objects/complexobject.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 81bcca8..138ba80 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -279,15 +279,12 @@ complex_to_buf(char *buf, int bufsz, PyComplexObject *v, int precision)
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);
}
}