Skip to content
Permalink
Browse files

prf.c: fix display of float exponent >= 100

The code accounts only for 2 exponent digits even though the exponent
may grow up to 308. Before this change, printf("%g", 1e300) would
produce "1e+N0".

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
  • Loading branch information...
Nicolas Pitre authored and nashif committed Jun 19, 2019
1 parent f286eda commit 132a286c396457e372e83b24b99238176dbc8239
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/libc/minimal/source/stdout/prf.c
@@ -407,6 +407,10 @@ static int _to_float(char *buf, uint64_t double_temp, char c,
} else {
*buf++ = '+';
}
if (decexp >= 100) {
*buf++ = (decexp / 100) + '0';
decexp %= 100;
}
*buf++ = (decexp / 10) + '0';
decexp %= 10;
*buf++ = decexp + '0';

0 comments on commit 132a286

Please sign in to comment.
You can’t perform that action at this time.