[ACCEPTED]-Representing Numbers in Exponential form-c#
Accepted answer
You'll need to use a custom format string 4 to specify how to format your decimal:
string.Format("{0:0.##E+00}", dValue);
You 3 can find more about custom numeric format 2 strings on the MSDN here. There's a specific 1 section on Exponent formats.
I think you want something like:
string text = dValue.ToString("0.###E+00");
(Change the number 6 of #
characters to change the number of decimal 5 digits before the E.)
You can do this with a compound 4 format specifier as well by calling string.Format
, but 3 personally I'd use a simple one unless you 2 need to put other text round it anyway, in 1 which case you'd use use something like:
string text = string.Format("Before {0:0.0###E+00} After", dValue);
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.