Problem with "roundf" function in KDS

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

Problem with "roundf" function in KDS

478 Views
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 Kudos
1 Reply

370 Views
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 Kudos