Beispiel #1
0
        void simplyfy()
        {
            int hcf = BasicLib.HCF(Numerator, Denominator);

            Numerator   /= hcf;
            Denominator /= hcf;
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        public static Rational Simplyfy(Rational r)
        {
            int hcf = BasicLib.HCF(r.Numerator, r.Denominator);

            return(new Rational(r.Numerator / hcf, r.Denominator / hcf));
        }