I have a float number that displays with a certain number of decimal places after it no matter what, even if it is a round number. How do I format it so that it only displays significant figures with no trailing zeros.
Asked
Active
Viewed 1,013 times
1
-
1Check out this answer http://stackoverflow.com/questions/560517/make-a-float-only-show-two-decimal-places – Yan Jul 23 '13 at 02:32
-
@yan you are absolutely right. – IKKA Jul 23 '13 at 05:49
-
@Yan Those answers all require you to know the number of digits. This question asks for significant digits, which could be "1.25" or "5" or "7.32816". – Nerrolken Aug 05 '15 at 17:53
-
Can't you use @Yan 's suggestion, after you have checked for non zero figures? – alasker Dec 01 '15 at 19:27