In this article I will show you about using BigInteger Class of the framework 4.0 that can perform arithmetic operations on integer values that can exceed the size of default numeric types. For example even largest one Int64.MaxValue.Numeric values in .net framework have some max and min values according to their memory allocation. BigInteger can deal with bigger integers such like 91389681247993671255432112000000 that is not performable by default data types.
C#, .NET 4.0
Suppose we want to do sum of 2 huge numbers that are bigger then Int64. We can perform the operation by BigInteger class.
First of all you need to import namespace.
Here I am showing screen shot of application.
You can perform basic operation like below code.
BigInteger bigInt1 = new BigInteger(123456789101112131415);
BigInteger bigInt2 = new BigInteger(123456789632312211212);
BigInteger Total = BigInteger.Add(bigInt1,bigInt2);
// Show the ResultTextBox3.Text = Total.ToString();
I am listing some methods of BigInteger class that can be useful for computing .
Many more methods are available that are useful for arithmatic operations.
We have just seen in this article how to deal with BigInteger Class of .net framework 4.0 to perform arithmetic operations on values that are bigger than default data types provided by .net framework.
Sample Project Source
Download source files -41 kb