On Thu, May 08, 2003 at 04:39:47PM +0000, Daniel Néri wrote:
> Pedro Zorzenon Neto <[email protected]> writes:
> 
> >    f = 1.54;
> >    sprintf(s,"%f",f);
> 
> There are two problems:
> 
> 1. Avoid sprintf and use snprintf instead.
> 
> 2. AFAICT, the s(n)printf implementation in msp430-libc does not
>    support floating point.
> 
> 
> Regards,
>    --Daniel
> 

Hi Daniel,

  You are right. %f does not work in sprintf.

  This worked for my needs. I know this it not an optimised example, but
works.

   char s[20];
   float f;
   f = 14.456;
   sprintf(s, "%02d,%03d", (uint) f, ((uint)((f - floor(f)) * 1000.0)) );

  Bye,
   Pedro

Reply via email to