I am having value double value = 1427799000;
I would like to convert it to scientific notation where the values exponent must always 10^11 (E+11).
I have tried following but it is not working.
Console.WriteLine(value.ToString("00.##E+11", CultureInfo.InvariantCulture));
Output should be : 0.14 x 10^11 or 0.14E+11
How to convert any double value to scientific notation with fixed exponent ? Here fixed exponent is 11.
To express a number in exponential notation, write it in the form: c × 10n, where c is a number between 1 and 10 (e.g. 1, 2.5, 6.3, 9.8) and n is an integer (e.g. 1, -3, 6, -2).
To multiply two numbers in scientific notation, multiply their coefficients and add their exponents. To divide two numbers in scientific notation, divide their coefficients and subtract their exponents.
double value = 1427799000;
Console.WriteLine(value.ToString("G2", CultureInfo.InvariantCulture));
//output: 1.4E+09
The General ("G") Format Specifier
The general ("G") format specifier converts a number to the most compact of either fixed-point or scientific notation, depending on the type of the number and whether a precision specifier is present.
EDIT: About your comment you can't display the scientific notation in your desirable way, it is not defined that way ! The coeficient must be greater or equal to 1 and less to 10.
For number 1.23*10^11 ->Article source
The first number 1.23 is called the coefficient. It must be greater than or equal to 1 and less than 10.
The second number is called the base . It must always be 10 in scientific notation. The base number 10 is always written in exponent form. In the number 1.23 x 10^11 the number 11 is referred to as the exponent or power of ten.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With