Problem with "roundf" function in KDS

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem with "roundf" function in KDS

1,283 次查看
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,175 次查看
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 项奖励
回复