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))); }
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)); }
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); }
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); }
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); }
// ---------------------------------------------------------- // 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); // 永远也不会走这里来 }
public abstract long Cut(); // 返回整数部分 public override XTNumericToken Calculate(string formula, XTFormulaArgs args) { return(this); }
public override XTNumericToken Calculate(string formula, XTFormulaArgs args) { XTNumericToken token = this.m_formulas[0].Calculate(args); return(new XTLongToken(token.Round())); }
public abstract XTNumericToken Calculate(string formula, XTFormulaArgs args);