Big Integer in .NET 4.0



In .Net 4.0, we have a new feature called Big Integer. Any values which can't hold by double or long can occupy by Big Integer.

BigInteger is there in System.Numerics.BigInteger.

Double can hold 16 bit values but Biginteger can hold any values. Let see the comparsion of Big Integer and Double.

Example:

System.Numerics.BigInteger biginteger = System.Numerics.BigInteger.Pow(2, 128);

Response.Write("BigInteger" + biginteger.ToString("N"));

Response.Write("<br>");

Response.Write("Double" + Math.Pow(2, 128).ToString("N"));

Response.Write("<br>");


Output:

BigInteger340,282,366,920,938,463,463,374,607,431,768,211,456.00
Double340,282,366,920,938,000,000,000,000,000,000,000,000.00

Handling very big values can be possible in .NET.


Recommended Free Ebook
Similar Articles