mirror of
https://git.musl-libc.org/git/musl
synced 2025-03-22 10:33:16 +03:00
fix printf rounding with %g for some corner case midpoints
the subsequent rounding code assumes the end pointer (z) accurately reflects the end of significance in the decimal expansion, but for certain large integers, spurious trailing zero slots were left behind when applying the binary exponent. issue reported by Morten Welinder; the analysis of the cause was performed by nsz, who also proposed this change.
This commit is contained in:
parent
efe07b0f89
commit
e94d069286
@ -308,8 +308,8 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
|
||||
*d = x % 1000000000;
|
||||
carry = x / 1000000000;
|
||||
}
|
||||
if (!z[-1] && z>a) z--;
|
||||
if (carry) *--a = carry;
|
||||
while (z>a && !z[-1]) z--;
|
||||
e2-=sh;
|
||||
}
|
||||
while (e2<0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user