简体   繁体   English

如何在C#中将非指数数字转换为指数数字

[英]How to convert non-Exponential numbers to Exponential number in c#

we have some calculation in our project like convertion from non-Exponential("1234567890.1234567890" numbers to Exponential("1.234567890E+10") number. 我们在项目中进行了一些计算,例如从非指数(“ 1234567890.1234567890”数字转换为指数(“ 1.234567890E + 10”)数字)的计算。

is there any solution for above issue? 以上问题有什么解决办法吗?

please help me to come out from this problem. 请帮助我摆脱这个问题。

It seems like you need to use Double.Parse (if you have the number as a string) and then Double.ToString with the appropriate format specifier . 似乎您需要使用Double.Parse (如果您将数字作为字符串),然后使用Double.ToString和相应的格式说明符 For example: number.ToString("E") 例如: number.ToString("E")

Use this. 用这个。

string.Format("{0:#.0#E-00}", NumericValue);

or 要么

string.Format("{0:E}", NumericValue);

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

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