From fd3a00f5f98559fca9e66b431765371ccbd1bef3 Mon Sep 17 00:00:00 2001 From: freedomDR <1640145602@qq.com> Date: Mon, 17 Feb 2025 21:21:39 +0800 Subject: [PATCH] Fix fpconv_dtoa when deal neg number --- src/fpconv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fpconv.cpp b/src/fpconv.cpp index a6246e43..52741d6c 100644 --- a/src/fpconv.cpp +++ b/src/fpconv.cpp @@ -235,7 +235,7 @@ static int emit_digits(char* digits, int ndigits, char* dest, int K, bool neg) { int exp = absv(K + ndigits - 1); /* write plain integer */ - if (K >= 0 && (exp < (ndigits + 7))) { + if (K >= 0 && (exp < (ndigits + 7 - neg))) { memcpy(dest, digits, ndigits); // intentionally fill with '0', not 0 (NUL byte) because // we want the string representation of the number zero