示例#1
0
        public override void SetString(string str)
        {
            TFrac TempFrac = new TFrac(str);

            Numerator   = TempFrac.Numerator;
            Denominator = TempFrac.Denominator;
        }
示例#2
0
        public override object Square()
        {
            TFrac temp;

            temp = new TFrac((TNumber)Numerator.Square(), (TNumber)Denominator.Square());
            return(temp);
        }
示例#3
0
        public override ANumber Sub(ANumber a)
        {
            TFrac temp;

            temp = new TFrac((a as TFrac).Numerator * Denominator - (a as TFrac).Denominator * Numerator, (a as TFrac).Denominator * Denominator);
            return(temp);
        }
示例#4
0
        public override ANumber Add(ANumber a)
        {
            TFrac temp;

            temp = new TFrac(Numerator * (a as TFrac).Denominator + Denominator * (a as TFrac).Numerator, Denominator * (a as TFrac).Denominator);
            return(temp);
        }
示例#5
0
        public static TFrac operator /(TFrac a, TFrac b)
        {
            TFrac temp;

            temp = new TFrac(a.Numerator * b.Denominator, a.Denominator * b.Numerator);
            return(temp);
        }
示例#6
0
        private string Number_to_state(string tag, string str)
        {
            if ("ERROR" == str)
            {
                return(str);
            }
            string return_str = str;

            switch (tag)
            {
            case TAG_PNUMBER:
                break;

            case TAG_FRAC:
                if (true == frac_mode)
                {
                    return_str = str;
                }
                else if (new TFrac(str).Denominator == 1)
                {
                    return_str = new TFrac(str).Numerator.ToString();
                }
                break;

            case TAG_COMPLEX:
                if (true == complex_mode)
                {
                    return_str = str;
                }
                else if (new TComplex(str).Imaginary == 0)
                {
                    return_str = new TComplex(str).Real.ToString();
                }
                break;
            }
            return(return_str);
        }
示例#7
0
文件: Form1.cs 项目: KateEnina/STP_2
        private string NumberBeatifier(string Tag, string str)
        {
            if (str == "ERROR")
            {
                return(str);
            }
            string ToReturn = str;

            switch (Tag)
            {
            case TAG_PNUMBER:
                break;

            case TAG_FRAC:
                if (FracMode == true)
                {
                    ToReturn = str;
                }
                else if (new TFrac(str).Denominator == 1)
                {
                    ToReturn = new TFrac(str).Numerator.ToString();
                }
                break;

            case TAG_COMPLEX:
                if (ComplexMode == true)
                {
                    ToReturn = str;
                }
                else if (new TComplex(str).Imaginary == 0)
                {
                    ToReturn = new TComplex(str).Real.ToString();
                }
                break;
            }
            return(ToReturn);
        }
示例#8
0
 public TFrac(TFrac anotherFrac)
 {
     Numerator   = anotherFrac.Numerator;
     Denominator = anotherFrac.Denominator;
 }