c# - 具有固定指数 C# 的科学记数法的双重值(value)

标签 c# double notation exponent

我的值 double value = 1427799000;

我想将其转换为科学记数法,其中值指数必须始终为 10^11 (E+11)。

我试过跟随,但它不起作用。

Console.WriteLine(value.ToString("00.##E+11", CultureInfo.InvariantCulture));

输出应为:0.14 x 10^11 或 0.14E+11

如何将任何 double 值转换为具有固定指数的科学记数法?这里的固定指数是 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.

关于c# - 具有固定指数 C# 的科学记数法的双重值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39824174/

相关文章:

c# - 无法修改 'Selectable.Colors' 的返回值,因为它不是变量

c# - Windows Phone 使用方向计算位置

string - Swift,将字符串转换为 double 错误

c++ - 为什么int提升为double而不是float进行隐式转换

algorithm - 循环的 O 符号

c# - 不能在类之间传递数据

C# 检测路径中的文件夹连接

ios - Swift - 将数组中的值转换为 double 或 float

c++ - 将图拆分为循环,然后拆分为路径

Excel VBA-如何用科学记数法识别单元格