I'm trying to format numbers as strings, but I don't want to use a fixed number of digits. I want to display only the number of fractional digits needed to fully represent the number. For example:
3.00000 would be formatted as "3"
3.12500 would be formatted as "3.125"
3.123456789 would be formatted as "3.123456789"
How can I tell String.format to pay attention to significant figures and produce a string that follows the above pattern?
If string.format doesn't have that ability, is there a class that will let me format numbers in this way?