Problem with "roundf" function in KDS

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

Problem with "roundf" function in KDS

1,278件の閲覧回数
sreeramadhanala
Contributor I

We are using Kinetis design studio version 3.2 for our application. In this IDE we are facing a problem with "roundf" of math library function.(explained in below)


 float val = 14.98967;

 float C_val = 0;

 C_val = roundf(val*100)/100;                            // Round off the value with two decimal places

the result for the above function in Code warrior  is  C_Val = 14.9900
    
But in KDS : C_Val = 14.9899998;

Is there any other method in KDS to get the value same as in Code warrior ?

Please suggest...

Regards

Dhanalakshmi

0 件の賞賛
返信
1 返信

1,170件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Sreerama Dhanalakshmi ,

I test on KDSv3.2 with FRDM-K64 board, the data also 14.9900 :

pastedImage_1.png


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信