AnsweredAssumed Answered

atof convension error

Question asked by Javier.Michael on Dec 15, 2015
Latest reply on Dec 16, 2015 by Clive One
Hi clive,

I encounter a problem in converting float string array to float then back to float string array.

I have this array acValue = "1000.1";

then float fValue = atof(acValue);

then what I got in fValue is 1000.0997

when I convert it again to string, for example
sprintf(acValue, "%f", fValue);

acValue became now 1000.0997

Do you have any idea why this happen?

I tried many ways to trick it, like strtok the string to two,
then convert the whole number and floating number.
converting the float alone will result to 0.1, but when I add 1000 to it, it now becomes 1000.0997

Im using STM32F103, IAR EWARM and NORTi for my OS.

Regards,

Mike

Outcomes