Convert a Float to a string
CountMurphy
Posts: 19
I am having what I hope is a very simple issue to work out. I have a couple functions what are doing some float math, I would like to output the results of said functions onto my computer's serial terminal. To do so I am using the FloatString Object to convert one of my floats to a string. If I have a float of 1357.4999
Even if I call the SetPrecision function, my output is being incorrectly rounded. Is there a way to convert my exact float to a string? Coming from a c++ c# world, this has been very frustrating. I think I've spent more time trying to cast variables then writting code for my project. Any help would be greatly appreicated.
serial.str(fs.FloatToString(1357.4999))prints out "1357.5".
Even if I call the SetPrecision function, my output is being incorrectly rounded. Is there a way to convert my exact float to a string? Coming from a c++ c# world, this has been very frustrating. I think I've spent more time trying to cast variables then writting code for my project. Any help would be greatly appreicated.
Comments
Jonathan