How to

format number as scientific/exponential

Published: 19. October 2011 | Updated: 19. October 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » Math
Tags: C# Formatting Math Text
Was this snippet helpful for you? YESYES / NONO

More info about exponential formatting on http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx#EFormatString
decimal number = 12345.67890m;

Console.WriteLine(number.ToString("E"));
Console.WriteLine(number.ToString("e"));
Console.WriteLine(number.ToString("E3"));
Console.WriteLine(number.ToString("E8"));
Console Output:
1.234568E+004
1.234568e+004
1.235E+004
1.23456789E+004
Send us feedback about this snippet »



Related Snippets: