void simplyfy() { int hcf = BasicLib.HCF(Numerator, Denominator); Numerator /= hcf; Denominator /= hcf; }
public static Rational HCF(Rational r1, Rational r2) { int n = BasicLib.HCF(r1.Numerator, r2.Numerator); int d = BasicLib.LCM(r1.Denominator, r2.Denominator); return(new Rational(n, d)); }
public Rational(double d, int dp) { int den = (int)Math.Pow(10, dp); int num = (int)(Math.Round(d, dp) * den); int hcf = BasicLib.HCF(num, den); Numerator = num / hcf; Denominator = den / hcf; }
public static Rational Simplyfy(Rational r) { int hcf = BasicLib.HCF(r.Numerator, r.Denominator); return(new Rational(r.Numerator / hcf, r.Denominator / hcf)); }