py/formatfloat: Workaround (fix?) incorrect rounding for %f format.

This commit is contained in:
Paul Sokolovsky 2015-11-22 18:09:28 +02:00
parent b64e0575fd
commit 3c4c069802
1 changed files with 3 additions and 1 deletions

View File

@ -308,7 +308,9 @@ int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int prec, ch
}
// Round
if (f >= FPCONST(5.0)) {
// If we print non-exponential format (i.e. 'f'), but a digit we're going
// to round by (e) is too far away, then there's nothing to round.
if ((org_fmt != 'f' || e <= 1) && f >= FPCONST(5.0)) {
char *rs = s;
rs--;
while (1) {