How to print the "negative float point number" to show negative value?

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

How to print the "negative float point number" to show negative value?

ソリューションへジャンプ
3,238件の閲覧回数
felix1
Contributor IV

If I use 

PRINTF("negative float test = %f", -1.234);

to print the negative float point number, I got the positive value from console, like

"negative float test = 1.234000"

Can you help me to fix it to show the real negative value?

p.s. define PRINTF_FLOAT_ENABLE=1

ラベル(1)
1 解決策
3,141件の閲覧回数
kbelete
NXP Employee
NXP Employee

Hi Felix,

Negative floating point values can be printed by opening the Project Properties and defining both “PRINTF_FLOAT_ENABLE” and “PRINTF_ADVANCED_ENABLE” to 1 in the Preprocessor settings. This is shown below using the hello_world SDK example project.

PrintNegativeFloats.png

Let me know if this solution works for you. If not, could you provide more details on your environment to help find a solution?

 

Regards,

Kaleb Belete

元の投稿で解決策を見る

2 返答(返信)
3,141件の閲覧回数
felix1
Contributor IV

Hi Kaleb,

Thanks for your right answer.

I want to ask another question about floating point number. 

I use CMSIS DSP library to do FFT (fast Fourier transform), this transform will use real number and complex number.

I use "Redlib (nohost-nf)" library now, and it seems ok to compile FFT API like "arm_rfft_fast_f32()".

Do I need to change the "Redlib (nohost-nf)" to another library for using floating point number?

0 件の賞賛
3,142件の閲覧回数
kbelete
NXP Employee
NXP Employee

Hi Felix,

Negative floating point values can be printed by opening the Project Properties and defining both “PRINTF_FLOAT_ENABLE” and “PRINTF_ADVANCED_ENABLE” to 1 in the Preprocessor settings. This is shown below using the hello_world SDK example project.

PrintNegativeFloats.png

Let me know if this solution works for you. If not, could you provide more details on your environment to help find a solution?

 

Regards,

Kaleb Belete