public void TestMethod1() { Rational r1 = new Rational(360,1); Rational r2 = new Rational(360, 7); Rational r3 = new Rational(360, 15); Rational r4 = new Rational(0.625, 3); Assert.AreEqual(new Rational(5, 8), r4); Rational rt = r2 * r3; Rational rd = r2 / r3; Rational rp = r2 + r3; Rational rm = r2 - r3; Debug.WriteLine("r1 as double is {0}", r1.ToDouble); Debug.WriteLine("r2 as double is {0}", r2.ToDouble); Debug.WriteLine("r2 * r3 is {0}", rt); Debug.WriteLine("r2 / r3 is {0}", rd); Debug.WriteLine("r2 + r3 is {0}", rp); Debug.WriteLine("r2 - r3 is {0}", rm); Rational r = Rational.LCM(r1, r2); Debug.WriteLine("LCM(r1,r2) is {0}",r); Rational rr = Rational.LCM(r, r3); Debug.WriteLine("LCM(r1,r2,r3) is {0}", rr); Debug.WriteLine(rr); Assert.AreEqual(r1, rr); }
public void Add(Rational n, double r, double phi) { base.Add(new RossStageData(n, r, phi)); }
public RossStageData() { Radius = 0; N = new Rational(); Phi = 0; }
} // phase angle public RossStageData(Rational n, double r, double phi) { N = n; Radius = r; Phi = phi; }
public static Rational Simplyfy(Rational r) { int hcf = BasicLib.HCF(r.Numerator, r.Denominator); return new Rational(r.Numerator / hcf, r.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); }