Share via


BigInteger in .NET

For a small personal project I've had to look for an implementation of a big integer, a class capable of working on numbers that are larger than integer data types supported natively by .NET compilers (numbers requiring more than 8 bytes) and to my great dismay I discovered that .NET FX 3.5 still does not provide such an implementation. Well, to be correct, it does provide it but .... it's internal to the .NET FX. And the reason for this is that the class was not ready for public use (but since it is used by some cryptographic classes it is there) thus the decision to make it internal. You can find this class under the System.Numeric namespace. One possibility could be to use it via reflection but then if you look on the internet you'll easily find a few alternatives. For example, you may find a few open-source implementations of a BigInteger (one is available on CodeProject.com and another one is here). An implementation of a BigInteger class is also part of the IronPython open-source project hosted at CodePlex (look for the class under the Microsoft.Scripting.Math namespace). This class seems to be a cut-down version of the class available in the .NET FX 3.5. One additional implementation of a BigInteger class is available inside the J# runtime library (vjslib.dll) and this time it is a public class (look under the java.math namespace): whatever programming language you are using (C#, VB.NET, etc.), add a reference to vjslib.dll in your .NET project and use it!

Comments