sprintf misbehaving with floats
Bob Dunlop
bob.dunlop@xyzzy.org.uk
Fri Jul 3 14:53:00 GMT 2015
Hi,
On Thu, Jul 02 at 05:58, Kline, Matthew wrote:
...
> But the following
>
> sprintf(foo, "%f is a float", 8675.309f);
>
> produces garbage similar to
Don't use floats very often myself so this is just speculation.
What happens is you try:
sprintf(foo, "%f is a float", 8675.309);
sprintf %f is expecting a double and I don't know if the compiler
will promote an explicitly set float to a double when passed as a
parameter.
Next I'd be looking at the storage that foo is pointing at. Is it
somewhere that might be overwritten or reused ?
--
Bob Dunlop
More information about the Newlib
mailing list