This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
sprintf bugs with floating point and field specifiers?
- From: "Matt Lee" <reachmatt dot lee at gmail dot com>
- To: newlib at sources dot redhat dot com
- Date: Tue, 5 Sep 2006 16:09:41 -0700
- Subject: sprintf bugs with floating point and field specifiers?
Hi,
I am seeing some bugs with Newlib sprintf and floating point format
specifiers. Specifically, the following bits of code work incorrectly,
<snip>
char chTest[200];
int main ()
{
sprintf(chTest, "%+05.1f", 0.03f); // "+00" --> wrong
printf("%s\n\r", chTest);
sprintf(chTest, "%05.0f", 0.03f); // "0000" --> wrong
printf("%s\n\r", chTest);
sprintf(chTest, "%+05.0f", 0.03f); // "+000" --> wrong
printf("%s\n\r", chTest);
}
</snip>
Output On Xilinx PowerPC 405 platform,
+00
0000
+000
while on desktop Linux I get,
+00.0
00000
+0000
I have tried both Newlib 1.9.0 and 1.14.0 and see the same behavior. I
am running a powerpc-eabi toolchain with Newlib configured for
floating point support.
I found a few email trails, that seem to discuss related issues but
were not really the same things? I will try to debug _dtoa_r() and
cvt(), but wanted to know if this is known behavior.
thanks,
Matt.