aboutsummaryrefslogtreecommitdiffstats
path: root/printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'printf.c')
-rw-r--r--printf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/printf.c b/printf.c
index 69c7ea7..418386a 100644
--- a/printf.c
+++ b/printf.c
@@ -303,16 +303,16 @@ static size_t _ftoa(double value, char* buffer, size_t maxlen, unsigned int prec
break;
}
}
-
+
// pad leading zeros
- while (!(flags & FLAGS_LEFT) && (len < prec) && (len < PRINTF_FTOA_BUFFER_SIZE)) {
- buf[len++] = '0';
- }
while (!(flags & FLAGS_LEFT) && (flags & FLAGS_ZEROPAD) && (len < width) && (len < PRINTF_FTOA_BUFFER_SIZE)) {
buf[len++] = '0';
}
// handle sign
+ if ((len == width) && (negative || (flags & FLAGS_PLUS) || (flags & FLAGS_SPACE))) {
+ len--;
+ }
if (len < PRINTF_FTOA_BUFFER_SIZE) {
if (negative) {
buf[len++] = '-';