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

5

27

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?

Picaroon answered 24/8, 2008 at 21:51 Comment(2)
Lack of a BigInt class is a major to you?Vain
It's a big deal if you are working on Project Euler #20 :-)Rawlings
Q
18

.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.

Quiberon answered 9/9, 2008 at 13:56 Comment(0)
K
13

.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

Kaitlinkaitlyn answered 24/8, 2008 at 21:56 Comment(0)
C
11

Microsoft.FSharp.Math.Types.BigInt

It can represent any integer.

Cockeye answered 25/8, 2008 at 20:12 Comment(0)
H
5

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

Halimeda answered 21/10, 2009 at 15:4 Comment(0)
O
4

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.

Opportuna answered 19/9, 2008 at 1:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.