Ejemplo n.º 1
0
        public override ElfNumber Multiply(ElfNumber n)
        {
            if (n is EsathCurrency)
            {
                return new EsathCurrency(base.Multiply(n));
            }

            return new EsathNumber(base.Multiply(n));
        }
Ejemplo n.º 2
0
        public override ElfNumber Divide(ElfNumber n)
        {
            if (n is EsathCurrency)
            {
                return new EsathCurrency(base.Divide(n));
            }

            return new EsathNumber(base.Divide(n));
        }
Ejemplo n.º 3
0
        public virtual ElfNumber Divide(ElfNumber n)
        {
            if (n.Val == 0)
            {
                throw new ErroneousScriptRuntimeException(ElfExceptionType.DivisionByZero, VM);
            }

            return Val / n.Val;
        }
Ejemplo n.º 4
0
        public override ElfNumber Subtract(ElfNumber n)
        {
            if (n is EsathPercent)
            {
                return new EsathCurrency(Val * (1 - n.Val));
            }

            return new EsathCurrency(base.Subtract(n));
        }
Ejemplo n.º 5
0
        public override ElfNumber Power(ElfNumber n)
        {
            if (n is EsathCurrency)
            {
                throw new ErroneousScriptRuntimeException(ElfExceptionType.OperandsDontSuitMethod, VM);
            }

            return new EsathCurrency(base.Power(n));
        }
Ejemplo n.º 6
0
        public override ElfNumber Add(ElfNumber n)
        {
            if (n is EsathPercent)
            {
                return new EsathCurrency(Val * (1 + n.Val));
            }

            return new EsathCurrency(base.Add(n));
        }
Ejemplo n.º 7
0
        public override ElfNumber Multiply(ElfNumber n)
        {
            if (n is EsathPercent)
            {
                return new EsathPercent(((1 + Val) * (1 + n.Val) - 1) * 100);
            }

            return n.Multiply(this);
        }
Ejemplo n.º 8
0
        public override ElfNumber Subtract(ElfNumber n)
        {
            if (n is EsathPercent)
            {
                return new EsathPercent(base.Subtract(n) * 100);
            }

            throw new ErroneousScriptRuntimeException(ElfExceptionType.OperandsDontSuitMethod, VM);
        }
Ejemplo n.º 9
0
        public override ElfNumber Add(ElfNumber n)
        {
            if (n is EsathPercent)
            {
                return new EsathPercent(base.Add(n) * 100);
            }

            return n.Add(this);
        }
Ejemplo n.º 10
0
        public override ElfNumber Divide(ElfNumber n)
        {
            if (n is EsathCurrency)
            {
                throw new ErroneousScriptRuntimeException(ElfExceptionType.OperandsDontSuitMethod, VM);
            }

            if (n is EsathPercent)
            {
                return new EsathPercent(((1 + Val) / (1 + n.Val) - 1) * 100);
            }

            return new EsathPercent(base.Divide(n) * 100);
        }
Ejemplo n.º 11
0
 public virtual ElfNumber Power(ElfNumber n)
 {
     return Math.Pow(Val, n.Val);
 }
Ejemplo n.º 12
0
 public virtual ElfNumber Multiply(ElfNumber n)
 {
     return Val * n.Val;
 }
Ejemplo n.º 13
0
 public virtual ElfNumber Subtract(ElfNumber n)
 {
     return Val - n.Val;
 }
Ejemplo n.º 14
0
 public virtual ElfNumber Add(ElfNumber n)
 {
     return Val + n.Val;
 }
Ejemplo n.º 15
0
        public static EsathCurrency PMT(ElfNumber rate, EsathNumber nper, EsathCurrency pv, EsathCurrency fv, EsathNumber type)
        {
            if (type != 0 && type != 1)
            {
                throw new ErroneousScriptRuntimeException(ElfExceptionType.OperandsDontSuitMethod, rate.VM);
            }

            if (rate is EsathCurrency)
            {
                throw new ErroneousScriptRuntimeException(ElfExceptionType.OperandsDontSuitMethod, rate.VM);
            }

            double result;
            if (rate == 0)
            {
                if (nper == 0)
                {
                    throw new ErroneousScriptRuntimeException(ElfExceptionType.DivisionByZero, rate.VM);
                }

                result = (-pv - fv) / nper;
            }
            else
            {
                result = (-pv * Math.Pow(1 + rate, nper) - fv) / ((1 + rate * type) * ((Math.Pow(1 + rate, nper) - 1) / rate));
            }

            return new EsathCurrency(result);
        }