Biginteger class C#

Biginteger class C# allows us to handle really large integer numbers, much larger then standard int. In order to use it, namespace System.Numerics has  to be included in the current project.

System-Numerics

In order to include namespace System.Numerics, just click as follows:

System-Numerics-add-Reference

Add Reference→.NET→System.Numerics

biginteger-class-c-sharp

Then include namespace in your project

using System.Numerics;

Coding example for calculate big int numbers in C# with Biginteger class C# is as follows:

BigInteger number = BigInteger.Pow(10, 10000);

or if we for example want to find reminder of 1010000 divided with 3123

BigInteger number = BigInteger.Pow(10, 10000);
BigInteger a = new BigInteger(Math.Pow(3.0, 123.0));
BigInteger remainder;

number = BigInteger.DivRem(number, a, out remainder);

External links:

Calculate big int numbers in C# using Biginteger class C# on YouTube
Calculate big int numbers in C# using Biginteger class C# on Stackoverflow

 

Posted in c-sharp-code-examples Tagged with: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*