public static IR.RealNumber operator +(IR.RealNumber a, IQ.RationalNumber b)
            {
                if (a.IsRational)
                {
                    if (a.N == 0)
                    {
                        return(IR.New(b));
                    }
                    else if (b.N == 0)
                    {
                        return(a);
                    }

                    return(IR.New(a.ToRational() + b));
                }

                if (a.Value.Value == 0)
                {
                    return(IR.New(b));
                }
                else if (b.N == 0)
                {
                    return(a);
                }

                return(IR.New(a.Value.Value * b.ApproximateValue));
            }
 public static RealNumber operator /(IR.RealNumber a, IZ.Integer b)
 {
     if (a.IsRational)
     {
         return(New(a.ToRational() / b));
     }
     return(IR.New(a.Value.Value / b.N));
 }
            public static RealNumber operator /(IZ.Integer a, IR.RealNumber b)
            {
                if (b.IsRational)
                {
                    return(New(a / b.ToRational()));
                }

                return(IR.New((decimal)a.N / b.Value.Value));
            }
            public static RealNumber operator *(IR.RealNumber a, IZ.Integer b)
            {
                if (a.IsRational)
                {
                    return(New(a.ToRational() * b));
                }

                return(IR.New(a.Value.Value * (decimal)b.N));
            }
            public static Integer operator +(decimal a, Integer b)
            {
                if (a == 0)
                {
                    return(b);
                }

                return(IR.New(a + (decimal)b.N));
            }
            public static Integer operator /(decimal a, Integer b)
            {
                if (a % 1 == 0)
                {
                    return(IQ.New((int)a, b.N));
                }

                return(IR.New(value: a / (decimal)b.N));
            }
            public static Integer operator /(Integer a, decimal b)
            {
                if (b % 1 == 0)
                {
                    return(IQ.New(a.N, (int)b));
                }

                return(IR.New(value: a.N / (int)b));
            }
            public static Integer operator *(decimal a, Integer b)
            {
                if (a % 1 == 0)
                {
                    return(New((int)a + b.N));
                }

                return(IR.New(a * (decimal)b.N));
            }
            public static RationalNumber operator /(RationalNumber a, decimal b)
            {
                if (a.N == 0)
                {
                    return(GetZeroDivideZeroRational());
                }

                if (b % 1 == 0)
                {
                    return(New(a.N, a.D * (int)b));
                }

                return(IR.New(a.ApproximateValue / b));
            }
예제 #10
0
            public static RationalNumber operator /(decimal a, RationalNumber b)
            {
                if (a == 0)
                {
                    return(IR.New(GetZeroDivideZeroRational()));
                }

                if (a % 1 == 0)
                {
                    return(New(b.D * (int)a, b.D));
                }

                return(IR.New(a / b.ApproximateValue));
            }
예제 #11
0
            public static RealNumber operator +(IR.RealNumber a, IZ.Integer b)
            {
                if (a.N == 0)
                {
                    return(New(b));
                }
                else if (b.N == 0)
                {
                    return(a);
                }

                if (a.IsRational)
                {
                    return(New(a.ToRational() + b));
                }

                return(IR.New(a.Value.Value + (decimal)b.N));
            }
예제 #12
0
            public static RationalNumber operator +(decimal a, RationalNumber b)
            {
                if (a == 0)
                {
                    return(b);
                }

                if (a % 1 == 0)
                {
                    if (b.N == 0)
                    {
                        return(New((int)a));
                    }

                    return(New(((int)a * b.D) + b.N, b.D));
                }

                return(IR.New(a + b.ApproximateValue));
            }
예제 #13
0
            public static IR.RealNumber operator /(IQ.RationalNumber a, IR.RealNumber b)
            {
                if (b.IsRational)
                {
                    if (a.N == 0)
                    {
                        return(IR.New(IQ.GetZeroDivideZeroRational()));
                    }

                    return(IR.New(a / b.ToRational()));
                }

                if (a.N == 0)
                {
                    return(IR.New(value: 0));
                }

                return(IR.New(value: a.ApproximateValue / b.Value.Value));
            }