views:

2968

answers:

5

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?

+10  A: 

.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

Haacked
+8  A: 

Microsoft.FSharp.Math.Types.BigInt

It can represent any integer.

Brian Leahy
+6  A: 

Also, FYI, I believe BigInteger will finally be public and consumable in the .NET Framework 4.0

jolson
+4  A: 

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.

Luke Quinane
+4  A: 

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

http://msdn.microsoft.com/en-us/library/system.numerics.biginteger%28VS.100%29.aspx

Shiraz Bhaiji