This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sprintf misbehaving with floats


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]