}// перетворити цілу частину в дробову public static Fraction operator +(Fraction a, Fraction b) { Fraction res = new Fraction(); res.numcator = a.GetSingNum() * a.numcator * b.denominator + b.GetSingNum() * b.numcator * a.denominator; res.denominator = a.denominator * b.denominator; res.GetIntPart(); res.intPart += a.intPart + b.intPart; res.reduce(); if (res.numcator < 0) { res.numcator *= -1; res.sing = false; } res.GetIntPart(); return(res); }
public static Fraction operator +(Fraction a, int b) { Fraction res = new Fraction(a); res.intPart += a.intPart + b; res.reduce(); if (res.intPart < 0) { res.intPart *= -1; res.sing = false; } res.GetIntPart(); return(res); }
public static Fraction operator *(Fraction a, Fraction b) { Fraction res = new Fraction(); a.SetFractionVaule(); b.SetFractionVaule(); res.numcator = a.numcator * b.numcator; res.denominator = a.denominator * b.denominator; if (a.sing != b.sing) { res.sing = false; } res.reduce(); res.GetIntPart(); return(res); }