Index: lib/sdk/crt/stdio/lnx_sprintf.c =================================================================== --- lib/sdk/crt/stdio/lnx_sprintf.c (revision 41280) +++ lib/sdk/crt/stdio/lnx_sprintf.c (working copy) @@ -184,8 +184,13 @@ if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' ) { - ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff); - exponent = ie/3.321928; + if(*n.__n == 0.0) + exponent = 0; + else + { + ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff); + exponent = ie/3.321928; + } } if ( exp_sign == 'g' || exp_sign == 'G' ) Index: lib/sdk/crt/stdlib/ecvtbuf.c =================================================================== --- lib/sdk/crt/stdlib/ecvtbuf.c (revision 41280) +++ lib/sdk/crt/stdlib/ecvtbuf.c (working copy) @@ -56,6 +56,9 @@ else *sign = 0; + if (ndigits<0) + ndigits = 0; + /* Special values get special treatment. */ if (strncmp (s, "Inf", 3) == 0) { @@ -74,6 +77,12 @@ while (*s && *s != decimal && d - buf < ndigits) *d++ = *s++; + /*From http://www.opengroup.org/onlinepubs/009695399/functions/gcvt.html: + the high order digit = 0. Returning 0 or 1 for decpt is unspecified. + Here we comply with the winetest for printf*/ + if(value == 0) + *decpt = 0; + else /* If we don't see any exponent, here's our decimal point. */ *decpt = d - buf; if (*s)