public BigNumber Append(BigNumber number) { this.bigNumberValue = this.bigNumberValue + number.bigNumberValue; return(this); }
public static BigNumber BigSum(this IEnumerable <BigNumber> values) { BigNumber l = values.Aggregate((h, t) => h + t); return(l); }
public static BigNumber operator *(BigNumber first, BigNumber second) { BigNumber returnValue = 0; BigNumber multiplacand; BigNumber multiplier; if (first < second) { multiplier = first; multiplacand = second; } else { multiplier = second; multiplacand = first; } for (int i = 0; i < multiplier.bigNumberValue.Length; i++) { int a = 0; int b = 0; if (multiplier.bigNumberValue.Length - i - 1 >= 0) { a = multiplier.bigNumberValue[multiplier.bigNumberValue.Length - i - 1].ConvertToInt(); } List <char> returnString = new List <char>(); int carry = 0; // Add 0's for the correct number of places. for (int z = 0; z < i; z++) { returnString.Add('0'); } for (int j = 0; j < multiplacand.bigNumberValue.Length; j++) { if (multiplacand.bigNumberValue.Length - j - 1 >= 0) { b = multiplacand.bigNumberValue[multiplacand.bigNumberValue.Length - j - 1].ConvertToInt(); } int result = a * b + carry; if (result > 9) { carry = result / 10; result = result % 10; } else { carry = 0; } returnString.Add(result.ConvertToChar()); } if (carry > 0) { returnString.Add(carry.ConvertToChar()); carry = 0; } returnString.Reverse(); returnValue += new BigNumber(new string(returnString.ToArray())); } return(returnValue); }