[En-Nut-Discussion] printf() variants return 0.00 - stack alignment?
harald.kipp at egnite.de
Tue Aug 13 09:50:42 CEST 2013
On 12.08.2013 19:03, Philipp Burch wrote:
> since some time, I'm facing an annoying problem when it comes to
> printing floating-point numbers using printf() variants (fprintf(),
> sprintf(), etc.). The problem always looks the same, instead of the
> actual value, there is only 0.000000 printed.
> As a (temporary) workaround, I would be happy with a simple function to
> convert a float into a string (which should also be somewhat faster than
> when working with doubles). Do you know a good implementation for this?
> I don't need those many formats (g, e, f) as printf() has, all I need is
> a variable number of decimal places and possibly automatic padding.
I looked into this some time ago. I remember I found a few simplified
routines, but none of them seem to work sufficiently well. In a next
step I tried to figure out the required algorithms. Specifically the
normalization (decimal shifting) is quite adventurous and the AT&T code
is not easy to follow.
Well, finally I came to the conclusion, that I better stay with the
newlib implementation (some versions are working) and spend my time in
fixed point routines, which would serve my needs better.
More information about the En-Nut-Discussion