Usermode/libc - printf fixes
authorJohn Hodge <[email protected]>
Fri, 15 Feb 2013 13:18:41 +0000 (21:18 +0800)
committerJohn Hodge <[email protected]>
Fri, 15 Feb 2013 13:18:41 +0000 (21:18 +0800)
Usermode/Libraries/libc.so_src/TEST_printf.c
Usermode/Libraries/libc.so_src/printf.c

index fe251d9..4376694 100644 (file)
@@ -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);
index bd67e00..9f39cc6 100644 (file)
@@ -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

UCC git Repository :: git.ucc.asn.au