PRINTF() question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PRINTF() question

665 Views
mspenard603
Contributor IV

Trying to left justify a float using PRINTF("%-4.2f", myfloat); But its not interpreting the -

How is this done?

0 Kudos
2 Replies

535 Views
lpcxpresso_supp
NXP Employee
NXP Employee

In the case you are using redlib, you have to remove "CR_INTEGER_PRINTF" define from project settings -> Compiler -> Preprocessor.

 

The effect should be like this:

      float x = 123.456;

      printf("++++++++++++++++\n");

      printf("%6.2f\n", x);

      printf("%9.2f\n", x);

      printf("%12.2f\n", x);

      printf("%-6.2f\n", x);

      printf("%-9.2f\n", x);

      printf("%-12.2f\n", x);

 

Output:

++++++++++++++++

123.46

   123.46

      123.46

123.46

123.46  

123.46  

 

More details on CR_INTEGER_PRINTF can be found on MCUXpresso_IDE_User_Guide.pdf, chapter "16.5.1 Redlib printf Variants", paragraph: "Integer only vs full printf (including floating point)"

 

Greetings,

MCUXpresso IDE Support

0 Kudos

535 Views
mspenard603
Contributor IV

The symbol #PRINTF_ADVANCED_ENABLE needs to be set. That adds support in.

0 Kudos