How can I format a float so that it doesn\'t contain trailing zeros? In other words, I want the resulting string to be as short as possible.
For example:
<
You can simply use format() to achieve this:
format(3.140, '.10g') where 10 is the precision you want.
format(3.140, '.10g')