From e58bc0ca9ef38b12cfce2a949875267d8a0803dd Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 15 Feb 2013 21:18:41 +0800 Subject: [PATCH] Usermode/libc - printf fixes --- Usermode/Libraries/libc.so_src/TEST_printf.c | 1 + Usermode/Libraries/libc.so_src/printf.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Usermode/Libraries/libc.so_src/TEST_printf.c b/Usermode/Libraries/libc.so_src/TEST_printf.c index fe251d9d..43766944 100644 --- a/Usermode/Libraries/libc.so_src/TEST_printf.c +++ b/Usermode/Libraries/libc.so_src/TEST_printf.c @@ -24,6 +24,7 @@ int main(int argc, char *argv[]) TST("Float", "%f", 3.1414926535); TST("Float", "%f", 10.0); + TST("Float", "%f", -0.0); TST("Float", "%.10f", 3.1414926535); TST("Float", "%e", 3.1415926535); TST("Float", "%g", 3.1415926535); diff --git a/Usermode/Libraries/libc.so_src/printf.c b/Usermode/Libraries/libc.so_src/printf.c index bd67e00f..9f39cc64 100644 --- a/Usermode/Libraries/libc.so_src/printf.c +++ b/Usermode/Libraries/libc.so_src/printf.c @@ -686,7 +686,7 @@ size_t _printf_ftoa(printf_putch_t putch_cb, void *putch_h, long double num, siz } den = 1; } - else + else if( num != 0.0 ) { while( den <= num ) den *= Base; @@ -701,7 +701,7 @@ size_t _printf_ftoa(printf_putch_t putch_cb, void *putch_h, long double num, siz else { } - num += precision_max/10 * 5; + num += precision_max/10 * 4.999; int value; // Whole section -- 2.20.1