mirror of
https://github.com/python/cpython.git
synced 2025-12-10 19:10:59 +00:00
patch [ 1118729 ] Error in representation of complex numbers(again)
This commit is contained in:
parent
bd9c3f7028
commit
c404ff2f2d
1 changed files with 3 additions and 6 deletions
|
|
@ -279,15 +279,12 @@ complex_to_buf(char *buf, int bufsz, PyComplexObject *v, int precision)
|
||||||
strncat(buf, "j", bufsz);
|
strncat(buf, "j", bufsz);
|
||||||
} else {
|
} else {
|
||||||
char re[64], im[64];
|
char re[64], im[64];
|
||||||
char *fmt;
|
/* Format imaginary part with sign, real part without */
|
||||||
PyOS_snprintf(format, 32, "%%.%ig", precision);
|
PyOS_snprintf(format, 32, "%%.%ig", precision);
|
||||||
PyOS_ascii_formatd(re, 64, format, v->cval.real);
|
PyOS_ascii_formatd(re, 64, format, v->cval.real);
|
||||||
|
PyOS_snprintf(format, 32, "%%+.%ig", precision);
|
||||||
PyOS_ascii_formatd(im, 64, format, v->cval.imag);
|
PyOS_ascii_formatd(im, 64, format, v->cval.imag);
|
||||||
if (v->cval.imag < 0.)
|
PyOS_snprintf(buf, bufsz, "(%s%sj)", re, im);
|
||||||
fmt = "(%s%sj)";
|
|
||||||
else
|
|
||||||
fmt = "(%s+%sj)";
|
|
||||||
PyOS_snprintf(buf, bufsz, fmt, re, im);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue