diff --git a/abstract-machine/klib/src/stdio.c b/abstract-machine/klib/src/stdio.c index 35f9f59..efcc671 100644 --- a/abstract-machine/klib/src/stdio.c +++ b/abstract-machine/klib/src/stdio.c @@ -123,13 +123,9 @@ void print_int_to_buf(char **buf, int *pos, int num, int width, char pad) { width--; } - if (reverse == 0) { - append_to_buffer(buf, pos, '0'); - } else { - while (reverse != 0) { - append_to_buffer(buf, pos, '0' + (reverse % 10)); - reverse /= 10; - } + for (int i = 0; i < count; i++) { + append_to_buffer(buf, pos, '0' + (reverse % 10)); + reverse /= 10; } }