Letter | Meaning |
---|---|
G or g | General |
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
Console.WriteLine("{0:G}", 1.2345);
Console.WriteLine("{0:G}", 0.00001);
Console.WriteLine("{0:g}", 1.2345);
Console.WriteLine("{0:G3}", 1.2345);
Console.WriteLine("{0:G}", 12345);
}
}
The output:
1.2345
1E-05
1.2345
1.23
12345
Format switches to exponential notation for small or large numbers.
G3 limits precision to three digits in total (before + after point).
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |