public static LargeNumber operator *(LargeNumber n1, LargeNumber n2) { if (n1.Numerator == 0 || n2.Numerator == 0) { return new LargeNumber (0, 1); } BigInteger numerator, denominator; numerator = n1.Numerator * n2.Numerator; denominator = n1.Denominator * n2.Denominator; var result = new LargeNumber (numerator, denominator); result.CutFraction (); return result; }
public static LargeNumber operator +(LargeNumber n1, LargeNumber n2) { BigInteger numerator, denominator; if (n1.Denominator != n2.Denominator) { denominator = n1.Denominator * n2.Denominator; numerator = n1.Numerator * n2.Denominator + n2.Numerator * n1.Denominator; } else { denominator = n1.Denominator; numerator = n1.Numerator + n2.Numerator; } var result = new LargeNumber (numerator, denominator); result.CutFraction (); return result; }
public static LargeNumber operator /(LargeNumber n1, LargeNumber n2) { BigInteger numerator, denominator; numerator = n1.Numerator * n2.Denominator; denominator = n2.Numerator * n1.Denominator; LargeNumber result = new LargeNumber (numerator, denominator); result.CutFraction (); return result; }