sprintf problem in MCF51QE128 and Codewarrior.

Discussion created by erooll on Jul 13, 2008
Latest reply on Sep 11, 2015 by PO220
Hi all.

I'm trying to use sprintf function to convert a float value to a string, but it doesn't work, this function with integer values works fine.
an example of use is this:

int   valueInteger;
float valueFloat;
char str[32];

valueInteger = 420;
valueFloat = 4.20;

sprintf(str,"%d",valueInteger);   //works fine
sprintf(str,"%f",valueFloat);     //Doesn't work

I read help of CodeWarrior about sprintf function and this note at the end of page could be the way to fix my problem


Floating point support increases the sprintf size considerably, and therefore the define LIBDEF_PRINTF_FLOATING exists. Set LIBDEF_PRINTF_FLOATING if no floating point support is used. Some targets contain special libraries without floating point support.
The IEEE64 floating point implementation only supports printing numbers with up to nine decimal digits. This limitation occurs because the implementation is using unsigned long internally, which cannot hold more digits. Supporting more digits increases the printf size still more and also causes the application to run considerably slower.

How I set LIBDEF_PRINTF_FLOATING in order to sprintf works?