2

I want to perform simple arithmetic operation in huge amount of number, as implement below

 string t = "22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222";
        //decimal number = 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222; Integral Constant is tooo large
        //long number = 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222; Integral Constant is tooo large

        //string ans = t / 2; // get answer in numeric form

How can i perform? any idea will be appreciated.

EDIT I am using 3.5 .net Framework.

Faraz Ahmed
  • 1,467
  • 2
  • 18
  • 33
  • use BigInteger....https://msdn.microsoft.com/en-us/library/system.numerics.biginteger_methods(v=vs.110).aspx in System.Numerics – Mitch Wheat Mar 10 '16 at 06:03
  • @user6002727 You can use long arithmetic, [read more about here](http://faculty.cse.tamu.edu/djimenez/ut/utsa/cs3343/lecture20.html) – tchelidze Mar 10 '16 at 06:05

2 Answers2

4

If you are using the.NET 4.0 you can use the System.Numerics.BigInteger class.

If you are using .Net 3.5 then you can use the Dynamic Language Runtime sources.

You can also check the IntX class

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • using Microsoft.Scripting.Utils; doesn't find in .netFramework3.5.. from your given Url : dlr.codeplex.com/sourcecontrol/changeset/view/40021#694008 – Faraz Ahmed Mar 10 '16 at 07:57
2

Add reference to System.Numerics.

using System.Numerics;

BigInteger i = BigInteger.Parse("22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222");

BigInteger

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541