Formatting doubles for output in C#
问题 Running a quick experiment related to Is double Multiplication Broken in .NET? and reading a couple of articles on C# string formatting, I thought that this: { double i = 10 * 0.69; Console.WriteLine(i); Console.WriteLine(String.Format(\" {0:F20}\", i)); Console.WriteLine(String.Format(\"+ {0:F20}\", 6.9 - i)); Console.WriteLine(String.Format(\"= {0:F20}\", 6.9)); } Would be the C# equivalent of this C code: { double i = 10 * 0.69; printf ( \"%f\\n\", i ); printf ( \" %.20f\\n\", i ); printf