private static Tuple<Fraction,Fraction> EqualFractions(Fraction fra1, Fraction fra2) { var denom1 = fra1.Denominator; var denom2 = fra2.Denominator; if (fra1.Numerator==0) { return new Tuple<Fraction, Fraction>(new Fraction (fra2.Numerator,fra2.Denominator), new Fraction { Numerator = 0, Denominator = 1 }); } else if(fra2.Numerator == 0) { return new Tuple<Fraction, Fraction>(new Fraction(fra1.Numerator,fra1.Denominator), new Fraction { Numerator = 0, Denominator = 1 }); } //simbolico devo sistemare prima mcm. int denom = 1; //var denom = Getmcm_factors(denom1, denom2); var numer1 = (denom / denom1) * fra1.Numerator; var numer2 = (denom / denom2) * fra2.Numerator; return new Tuple<Fraction, Fraction>(new Fraction(numer1,denom), new Fraction(numer2,denom)); }
public static Fraction operator /(int n, Fraction fra1) { var fra1Reciproco = new Fraction(fra1.Denominator, fra1.Numerator); var nFraction = new Fraction(n, 1); return nFraction * fra1Reciproco; }
public static Fraction operator /(Fraction fra1, int n) { var fra2Reciproco = new Fraction(1, n); return fra1 * fra2Reciproco; }
//quoziente public static Fraction operator /(Fraction fra1, Fraction fra2) { var fra2Reciproco = new Fraction(fra2.Denominator, fra2.Numerator); return fra1 * fra2Reciproco; }
public static Fraction operator *(Fraction fra1, int n) { var fractionN = new Fraction(n); return fractionN * fra1; }
public static Fraction operator -(int n, Fraction fra1) { var fractionN = new Fraction(n); return fra1 - fractionN; }
public static Fraction operator +(Fraction fra1, int n) { var fractionN = new Fraction(n); return fra1 + fractionN; }