I have float values from 00.00 to 99.99 range. I am trying to convert the float value to a string along with the conversion should remove decimal separator.
flaot a = 00.17;
float b = 08.56;
To remove decimal separator I am multiplying with *100 and converting to string using ftoa() function.
a = a*100;
b = b*100;
ftoa(a, 0, temp_string);
puts(temp_string);
ftoa(b, 0, temp_string);
output is: 17, 856, 2898
My output string should look like this
output: 0017,0856,2898
I can add 0's to string with a condition whether the number is below 99 add two zero's and if above 99 and below 999 add one zero.
Is there any best method to do this work?
floatvalues always be nearxx.yy000..., in which case this good answer suffices. But if you want the best answer for values near ``xx.yy5000...`, additional work is needed.