From b4d07616a396dd22fdc9809d1cc7e776d4891852 Mon Sep 17 00:00:00 2001 From: Gavin Hayes Date: Wed, 17 Aug 2022 14:16:40 -0400 Subject: [PATCH] stdio fmt: fix %.0g by treating it the same as %.1g --- libc/stdio/dtoa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/stdio/dtoa.c b/libc/stdio/dtoa.c index 7e4ba24a0..7622f2561 100644 --- a/libc/stdio/dtoa.c +++ b/libc/stdio/dtoa.c @@ -335,10 +335,10 @@ int __fmt_dtoa(int (*out)(const char *, void *, size_t), void *arg, int d, case 'G': case 'g': if (!(flags & FLAGS_PRECISION)) prec = 6; - if (prec < 0) prec = 0; + if (prec < 1) prec = 1; if (!longdouble) { x = va_arg(va, double); - s = s0 = dtoa(x, prec ? 2 : 0, prec, &decpt, &fpb.sign, &se); + s = s0 = dtoa(x, 2, prec, &decpt, &fpb.sign, &se); if (decpt == 9999) { if (s && s[0] == 'N') { fpb.kind = STRTOG_NaN;