From: John Hodge Date: Fri, 15 Feb 2013 13:18:41 +0000 (+0800) Subject: Usermode/libc - printf fixes X-Git-Tag: rel0.15~569 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=e58bc0ca9ef38b12cfce2a949875267d8a0803dd;p=tpg%2Facess2.git Usermode/libc - printf fixes --- 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