How to format floating point value with fix number of digits?
问题 Is it possible in C# to format a double value with double.ToString in a way that I have always a fixed number of digits, no matter on which side of the decimal point? Say I wish 6 digits, I want to have these results: 0.00123456789 gives "0.00123" 1.23456789 gives "1.23457" 123.456789 gives "123.457" 0.0000000123456789 gives "0.00000" 12345678.9 gives "12345679" (on overflow I want to see all digits left of decimalpoint) 4.2 gives "4.20000" I'm experimenting with double.ToString, but cannot