From 7543fadfa88d071798bc9c86cef40defd4a8a5b1 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 11 May 2023 18:20:37 +0300 Subject: [PATCH] LibC: printf now prints 0 as integer --- libc/printf_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libc/printf_impl.cpp b/libc/printf_impl.cpp index c6194d51..6d19fb7a 100644 --- a/libc/printf_impl.cpp +++ b/libc/printf_impl.cpp @@ -54,6 +54,9 @@ static void integer_to_string(char* buffer, T value, int base, bool upper, const value = -(value / base); } + if (value == 0 && width > 0) + buffer[offset++] = '0'; + while (value) { buffer[offset++] = digit_char(value % base, upper);