public static void TestBigInteger() { BigInteger first = new BigInteger("100000000000000000000000000000003453453453"); BigInteger secod = new BigInteger("100000000000000000000000000000003453453453"); BigInteger jami = BigInteger.Add(first, secod); Console.WriteLine(jami.StringValue); }
public static BigInteger Add(BigInteger first, BigInteger second) { // first = 2000; // second = 0010; if (first.Sign != -1 && second.Sign != -1) { string s = ""; int reminder = 0; for (int i = first.StringValue.Length - 1; i >= 0; i--) { int a = int.Parse("" + first.StringValue[i]); int b = int.Parse("" + second.StringValue[i]); int res = (a + b + reminder)%10; reminder = (a + b + reminder) / 10; s = s.Insert(0, res.ToString()); } if( reminder > 0) s = s.Insert(0, reminder.ToString()); return new BigInteger(s); } return null; }
public static BigInteger Subtract(BigInteger first, BigInteger second) { return null; }