How can I represent a very large integer in .NET?

2019-01-09 03:07发布

Does .NET come with a class capable of representing extremely large integers, such as 100 factorial? If not, what are some good third party libraries to accomplish this?

标签: .net bignum
5条回答
唯我独甜
2楼-- · 2019-01-09 03:10

Mono has a public BigInteger implementation already:

http://www.go-mono.com/docs/index.aspx?link=T:Mono.Math.BigInteger

You can just grab the Mono.Security assembly to use it; since its a Mono class library it should be MIT licensed too.

查看更多
We Are One
3楼-- · 2019-01-09 03:12

Microsoft.FSharp.Math.Types.BigInt

It can represent any integer.

查看更多
叛逆
4楼-- · 2019-01-09 03:23

Here is a link the documentation of big integer in framework 4.0

http://msdn.microsoft.com/en-us/library/system.numerics.biginteger(VS.100).aspx

查看更多
劳资没心,怎么记你
5楼-- · 2019-01-09 03:35

.NET has a BigInteger class, but it is internal, unfortunately. However, several places have their own. You can grab an implementation from IronPython, or the one from CodeProject, or from Visual J#. I have to say, I've not tried these myself, so I don't know which one is the best.

http://www.codeplex.com/IronPython http://www.codeproject.com/KB/cs/biginteger.aspx http://msdn.microsoft.com/en-us/magazine/cc163696.aspx

查看更多
Explosion°爆炸
6楼-- · 2019-01-09 03:36

.NET 4 has a BigInteger class

Represents an arbitrarily large signed integer.

The BigInteger type is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds. This type differs from the other integral types in the .NET Framework, which have a range indicated by their MinValue and MaxValue properties.

查看更多
登录 后发表回答