Displaying floating point value
Hello there :)
I have float variables which I need to display (and thus convert to string), and I'm looking for what would be the right way to format the output nicely.
I want it to have only one digit after the separator, and not have anything if there is no decimal value.
So 25.37000 would output 25.3, and 37.0 would output 37.
I can limit the output to one digit after the dot like this:
But the problem is that will still have the ".0" at the end, even if the value is round.
I could go with something like replace(",0", "") but somehow I feel there's a better way to do it. Calling the replace function just to remove two characters from what used to be a float variable seems a bit overkill and unadapted.