예제 #1
0
파일: UnitTest1.cs 프로젝트: dolkensp/OTWB
        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);
        }
예제 #2
0
 public void Add(Rational n, double r, double phi)
 {
     base.Add(new RossStageData(n, r, phi));
 }
예제 #3
0
 public RossStageData()
 {
     Radius = 0;
     N      = new Rational();
     Phi    = 0;
 }
예제 #4
0
        }                                         // phase angle

        public RossStageData(Rational n, double r, double phi)
        {
            N      = n;
            Radius = r;
            Phi    = phi;
        }
예제 #5
0
파일: Rational.cs 프로젝트: dolkensp/OTWB
 public static Rational Simplyfy(Rational r)
 {
     int hcf = BasicLib.HCF(r.Numerator, r.Denominator);
     return new Rational(r.Numerator / hcf, r.Denominator / hcf);
 }
예제 #6
0
파일: Rational.cs 프로젝트: dolkensp/OTWB
 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);
 }