Re: [arm-gnu] sprintf issue on Cortex-M3
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [arm-gnu] sprintf issue on Cortex-M3



Norbert Unterberg schrieb:
Hi,

we are using arm-none-eabi-gcc (Sourcery G++ Lite 2009q3-68) 4.4.1.

Formatting a floating point number with sprintf does not seem to work:

   char b[20];
   float temperature = 0.4f;
   sprintf(b, "%6.1f ", temperature);

prints "  -0.0" into the buffer.

I have searched the mailing list and have found an article from
September 9 ("output of sprintf with double-input"), but I did not
understand the solution posted there.
My "solution" there only fixed the little hello world problem.
I had no time to find out what exactly happened and it would be nice if someone could explain in more detail.

At that time I only saw that the problem was not located on sprintf in particular, but on variadic functions. As a test I used the average function of http://en.wikipedia.org/wiki/Variadic_function -> function va_arg (ap, double) always returns 0.

Regards,
Klaus