I have a long list of floating point numbers to be formatted as follows:
Examples:
case 1) 6.0 -> 6.0
(No trailing zeros)
case 2) 1.23456789 -> 1.234567
(or 1.234568
) (Max precision of 6)
case 3) 0.000004 -> 0.000004
(No exponent)
I can use
'{}'.format(round(x, 6))
for cases 1 & 2 but 3 gives 4e-06
If I use
'{:6f}'.format(6.0)
I get 6.000000 for case 1)
Is there a clean way to get the formatting I want?