Sometimes I need double to be printed with 1 decimal (when it has the same value as integer), sometimes I need double to be printed with 6 decimals.
For example:
0.000 should be printed as 0.0
1.000 should be printed as 1.0
1.200 should be printed as 1.200000
1.123456789 should be printed as 1.234568
How can I do this?
Commentary on possible duplicate
I am not sure my question is a duplicate of the other post. I am interested in a VARIABLE number of decimals. That is not touched upon there, as far as I can tell.