sscanf function unable to copy float value in STM32CubeIDE
I have win forms GUI and sending data from this GUI to STM32 Nucleo L4R5ZI µC over UART in byte array format. After receiving data over UART in µC, I am converting the data to their native formats such as Int ad Float. I don't have issue converting int, but float data is converted with too much precision i.e) 1.3 from GUI is converted as 1.29999995 in cubeIDE. That'y I implemented a function with sprintf and sscanf to convert 1.29999995 to 1.3. Sprintf copied the value to str (str is char array) 1.30, but sscanf is unable to copy the value back to float variable. Please have a look at the image for more info and also have a look at the code snippet. Please help me in this regard.
float conv(float var)
{
convvar = var;
sprintf(str, "%.2f", convvar);
// scan string value in var
sscanf(str, "%f", &convvar);
return convvar;
}
