具有固定指数 C# 的科学记数法的双重价值
Double value to scientific notation with fixed exponent C#
我很有价值double value = 1427799000;
我想将其转换为科学计数法,其中指数值必须始终为 10^11 (E+11)。
我试过跟随,但没用。
Console.WriteLine(value.ToString("00.##E+11", CultureInfo.InvariantCulture));
输出应该是:0.14 x 10^11 or 0.14E+11
如何将双精度值转换为固定指数的科学计数法?这里的固定指数是 11.
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.
编辑:关于您的评论,您不能以您想要的方式显示科学记数法,它不是那样定义的!系数必须大于或等于 1 且小于 10。
对于数字 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.
我很有价值double value = 1427799000;
我想将其转换为科学计数法,其中指数值必须始终为 10^11 (E+11)。
我试过跟随,但没用。
Console.WriteLine(value.ToString("00.##E+11", CultureInfo.InvariantCulture));
输出应该是:0.14 x 10^11 or 0.14E+11
如何将双精度值转换为固定指数的科学计数法?这里的固定指数是 11.
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.
编辑:关于您的评论,您不能以您想要的方式显示科学记数法,它不是那样定义的!系数必须大于或等于 1 且小于 10。
对于数字 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.