コード例 #1
0
        public override XTNumericToken Calculate(string formula, XTFormulaArgs args)
        {
            XTNumericToken baseToken  = this.m_formulas[0].Calculate(args);
            XTNumericToken indexToken = this.m_formulas[1].Calculate(args);

            return(new XTDoubleToken(Math.Pow((double)baseToken, 1.0f / (double)indexToken)));
        }
コード例 #2
0
        public override XTNumericToken Calculate(string formula, XTFormulaArgs args)
        {
            XTNumericToken lToken = this.m_formulas[0].Calculate(args);
            XTNumericToken rToken = this.m_formulas[1].Calculate(args);

            return(new Random().Next((int)lToken, (int)rToken));
        }
コード例 #3
0
        public override XTNumericToken Calculate(string formula, XTFormulaArgs args)
        {
            XTNumericToken token;

            if (args.TryGetValue(this.m_name, out token))
            {
                return(token);
            }
            throw new XTFormulaNoArgumentException(formula, this.m_name);
        }
コード例 #4
0
        public override XTNumericToken Calculate(string formula, XTFormulaArgs args)
        {
            XTNumericToken lToken = this.m_formulas[0].Calculate(args);
            XTNumericToken rToken = this.m_formulas[1].Calculate(args);

            if (lToken > rToken)
            {
                return(rToken);
            }
            return(lToken);
        }
コード例 #5
0
        public XTNumericToken Calculate(XTFormulaArgs args)
        {
            if (this.m_result != null)
            {
                return(this.m_result);
            }

            XTNumericToken token = this.m_root.Calculate(this.m_formula, args);

            if (this.IsConst)
            {
                this.m_result = token;
            }
            return(token);
        }
コード例 #6
0
        // ----------------------------------------------------------
        // public
        // ----------------------------------------------------------
        public override XTNumericToken Calculate(string formula, XTFormulaArgs args)
        {
            XTNumericToken rValue = this.m_rToken.Calculate(formula, args);

            if (this.m_lToken == null)
            {                   // 以 +、- 号开头的公式
                return((this.m_opt == Operator.Sub) ? -rValue : rValue);
            }
            XTNumericToken lValue = this.m_lToken.Calculate(formula, args);

            switch (this.m_opt)
            {
            case Operator.Or:
                return(lValue | rValue);

            case Operator.Xor:
                return(lValue ^ rValue);

            case Operator.And:
                return(lValue & rValue);

            case Operator.LMove:
                return(lValue << (int)rValue);

            case Operator.RMove:
                return(lValue >> (int)rValue);

            case Operator.Add:
                return(lValue + rValue);

            case Operator.Sub:
                return(lValue - rValue);

            case Operator.Mul:
                return(lValue * rValue);

            case Operator.Div:
                return(lValue / rValue);

            case Operator.Mod:
                return(lValue % rValue);

            case Operator.Pow:
                return(Math.Pow((double)lValue, (double)rValue));
            }
            return(rValue);                     // 永远也不会走这里来
        }
コード例 #7
0
        public abstract long Cut();                     // 返回整数部分

        public override XTNumericToken Calculate(string formula, XTFormulaArgs args)
        {
            return(this);
        }
コード例 #8
0
        public override XTNumericToken Calculate(string formula, XTFormulaArgs args)
        {
            XTNumericToken token = this.m_formulas[0].Calculate(args);

            return(new XTLongToken(token.Round()));
        }
コード例 #9
0
 public abstract XTNumericToken Calculate(string formula, XTFormulaArgs args);