简体   繁体   English

从指数符号转换为非指数符号

[英]Convert from exponential notation to non-exponential notation

I have tried: 我努力了:

MessageBox.Show(System.Numerics.BigInteger.Parse("7.56e+011",
          NumberStyles.Float,
          CultureInfo.InvariantCulture));

But it continues to show 7.56e+011 但它仍然显示7.56e + 011

You are looking to format the number. 您正在寻找格式化数字。 You can use String.Format to do so 您可以使用String.Format这样做

string.Format("{0:F}",System.Numerics.BigInteger.Parse("7.56e+011",
          NumberStyles.Float,
          CultureInfo.InvariantCulture))

Running the following code 运行以下代码

VS2012中的代码

Gives you the following MessageBox 为您提供以下消息框

带字符串的MessageBox

you can specify no decimal points by changing it to {0:F0} for the format. 您可以通过将格式更改为{0:F0}来指定小数点。

    decimal dec = decimal.Parse("7.7583877127496407E-6", 
    System.Globalization.NumberStyles.Any);
    Console.WriteLine(dec);

Try 尝试

BigInteger num = System.Numerics.BigInteger.Parse("7.56e+011",
      NumberStyles.Float,
      CultureInfo.InvariantCulture);

String text = num.ToString("F5"); // New format string, here with 5 digits. 

Your solution does an implicit conversion from BigInteger back to string again, which uses the scientific notation if the exponent is large. 您的解决方案再次从BigInteger隐式转换回字符串,如果指数很大,则使用科学计数法。

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

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