If I want to display, say, 4 decimal points, what is the correct format?
+6
A:
String.Format("{0:0.0000}", floatNum);
That will always display four decimal places, regardless of what the value is. Other options can be found here: http://www.csharp-examples.net/string-format-double/
Mark Kinsella
2010-02-12 19:07:09
A:
Notice that it rounds:
decimal d = 1.23456789M;
Console.WriteLine(d.ToString("0.0000"));
// Output: 1.2345
As a format string, it would be:
Console.WriteLine("{0:0.0000}", d);
David
2010-02-12 19:07:10