Part Number: TMS320F28379D
Hello Experts ,
I would like to truncate a float32 variable to its 2 decimal places, Currently I am doing the below, Could you please let me know if there is a better way, I would like to avoid any division operation.
#include <math.h> //Round to 2 decimal places //Option 1: float32_t currentMechTheta = 0.3278; currentMechTheta = floorf(pMotor->ptrFCL->qep.MechTheta * 100) / 100; //0.3200 //Option 2: float32_t currentMechTheta = 0.3278; currentMechTheta = roundf(pMotor->ptrFCL->qep.MechTheta * 100) / 100; //0.3300