.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Arithmetic operations on Numbers bigger than permissible limits

Posted By:Kirtan       Posted Date: April 23, 2010    Points: 25    Category: .Net Framework    URL: http://www.dotnetspark.com  

In this article I will show you about using BigInteger Class of the framework 4.0.


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.


CSharp .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 name space...

using System.Numerics;

Here I am showing screen shot of application.

   private void button1_Click(object sender, EventArgs e)
            BigInteger b1 = BigInteger.Parse(textBox1.Text);
            BigInteger b2 = BigInteger.Parse(textBox2.Text);

            BigInteger total = BigInteger.Add(b1, b2);
            textBox3.Text = total.ToString();
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 Result
TextBox3.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 arithmetic 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.
 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend