PRINTF() question

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

PRINTF() question

1,727件の閲覧回数
mspenard603
Contributor IV

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

How is this done?

0 件の賞賛
返信
2 返答(返信)

1,597件の閲覧回数
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 件の賞賛
返信

1,597件の閲覧回数
mspenard603
Contributor IV

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

0 件の賞賛
返信