简体   繁体   English

使用固定指数 C# 将双值转换为科学记数法

[英]Double value to scientific notation with fixed exponent C#

I am having value double value = 1427799000;我有价值double value = 1427799000;

I would like to convert it to scientific notation where the values exponent must always 10^11 (E+11).我想将其转换为科学记数法,其中值指数必须始终为 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输出应该是: 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.这里的固定指数是 11。

double value = 1427799000;
Console.WriteLine(value.ToString("G2", CultureInfo.InvariantCulture));

//output: 1.4E+09

The General ("G") Format Specifier 通用(“G”)格式说明符

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.通用(“G”)格式说明符将数字转换为最紧凑的定点记数法或科学记数法,具体取决于数字的类型以及是否存在精度说明符。

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.系数必须大于或等于 1 且小于 10。

For number 1.23*10^11 -> Article source对于数字 1.23*10^11 ->文章来源

The first number 1.23 is called the coefficient.第一个数字 1.23 称为系数。 It must be greater than or equal to 1 and less than 10.它必须大于或等于 1 且小于 10。

The second number is called the base .第二个数字称为基数。 It must always be 10 in scientific notation.在科学记数法中它必须始终为 10。 The base number 10 is always written in exponent form.基数 10 总是以指数形式书写。 In the number 1.23 x 10^11 the number 11 is referred to as the exponent or power of ten.在数字 1.23 x 10^11 中,数字 11 被称为十的指数或幂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM