c#中的数据类型用于查找阶乘

c#中的数据类型用于查找阶乘,第1张

概述c#中最大的数据类型是什么,或者我应该使用哪种数据类型来查找1619的阶乘.我尝试了ulong和uint64,但是他们修改了我的答案. 看这个 https://msdn.microsoft.com/en-us/library/system.numerics.biginteger%28v=vs.110%29.aspx BigInteger是不是更快,但可以计算大数字 这里和MSDN的简单示例 str c#中最大的数据类型是什么,或者我应该使用哪种数据类型来查找1619的阶乘.我尝试了ulong和uint64,但是他们修改了我的答案.解决方法 看这个 https://msdn.microsoft.com/en-us/library/system.numerics.biginteger%28v=vs.110%29.aspx

BigInteger是不是更快,但可以计算大数字

这里和MSDN的简单示例

string positiveString = "91389681247993671255432112000000";string negativeString = "-90315837410896312071002088037140000";BigInteger posBigInt = 0;BigInteger negBigInt = 0;    try     {         posBigInt = BigInteger.Parse(positiveString);         Console.Writeline(posBigInt);    }    catch (FormatException)    {         Console.Writeline("Unable to convert the string '{0}' to a BigInteger value.",positiveString);    }

我尝试了自己的榜样并且正在努力

string positiveString = "91389681247993671255432112000000";string negativeString = "-90315837410896312071002088037140000";BigInteger b = BigInteger.Parse(positiveString);BigInteger c = BigInteger.Parse(positiveString);BigInteger d = b * c;System.Console.Writeline(d);System.Console.Readline();// result 835207383860988607360648144841987935757186784078054400000000000
总结

以上是内存溢出为你收集整理的c#中的数据类型用于查找阶乘全部内容,希望文章能够帮你解决c#中的数据类型用于查找阶乘所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1231978.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存