Ejemplo n.º 1
0
            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));
            }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
            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));
            }
Ejemplo n.º 4
0
            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));
            }
Ejemplo n.º 5
0
            public static Integer operator +(decimal a, Integer b)
            {
                if (a == 0)
                {
                    return(b);
                }

                return(IR.New(a + (decimal)b.N));
            }
Ejemplo n.º 6
0
            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));
            }
Ejemplo n.º 7
0
            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));
            }
Ejemplo n.º 8
0
            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));
            }
Ejemplo n.º 9
0
            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));
            }
Ejemplo n.º 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));
            }
Ejemplo n.º 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));
            }
Ejemplo 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));
            }
Ejemplo n.º 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));
            }