Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 有没有一种方法可以像这样转换double-1.2676506002282294E+;“30至正常”;“非指数”;符号_C#_Double - Fatal编程技术网

C# 有没有一种方法可以像这样转换double-1.2676506002282294E+;“30至正常”;“非指数”;符号

C# 有没有一种方法可以像这样转换double-1.2676506002282294E+;“30至正常”;“非指数”;符号,c#,double,C#,Double,如何将Math.Pow(21000)从 1.0715086071862673E+301 到 107150860718626732094842504906000118105140481170553607443750388370351124936122493198378815695581275946729175531468258714528569231404359845774698574857480334567482423098542107460562371141875418215364749835

如何将
Math.Pow(21000)

1.0715086071862673E+301

到 1071508607186267320948425049060001181051404811705536074437503883703511249361224931983788156955812759467291755314682587145285692314043598457746985748574803345674824230985421074605623711418754182153647498358194126739876761655946077069145711964776767676766042316526286767656680376


那是因为我需要找到这个数字的所有数字之和。谢谢大家!

您可以使用System.Numerics中的BigInteger。它有自己的Pow方法

System.Numerics.BigInteger bigInteger = System.Numerics.BigInteger.Pow(2, 1000);

string powString = bigInteger.ToString();

int sum = 0;

foreach (char letter in powString)
{
    int letterValue = int.Parse(letter.ToString());
    sum += letterValue;
}

Console.WriteLine(sum);

我得到1366。

您可以使用System.Numerics中的BigInteger。它有自己的Pow方法

System.Numerics.BigInteger bigInteger = System.Numerics.BigInteger.Pow(2, 1000);

string powString = bigInteger.ToString();

int sum = 0;

foreach (char letter in powString)
{
    int letterValue = int.Parse(letter.ToString());
    sum += letterValue;
}

Console.WriteLine(sum);

我得到1366英镑。

你不能兑换;你已经失去了精确性。使用
biginger
。谢谢!它起作用了…你不能转换;你已经失去了精确性。使用
biginger
。谢谢!它起作用了。。。