public FormulaObject Pow(FormulaObject obj) { var intResult = 0; var result = Mathf.Pow(float.Parse(value), float.Parse(obj.value)); if (int.TryParse(value, out intResult)) { intResult = (int)result; } return(new FormulaObject(intResult.ToString())); }
public FormulaObject Operate(FormulaObject obj, FormulaNodeType type) { switch (type) { case FormulaNodeType.Add: { return(this + obj); } case FormulaNodeType.Minus: { return(this - obj); } case FormulaNodeType.Mul: { return(this * obj); } case FormulaNodeType.Divid: { return(this * obj); } case FormulaNodeType.Pow: { return(Pow(obj)); } case FormulaNodeType.Sqrt: { return(Log(new FormulaObject("2"))); } case FormulaNodeType.Log: { return(Log(obj)); } } return(this); }
public FormulaObject Log(FormulaObject obj) { obj = new FormulaObject("1.0") / obj; return(Pow(obj)); }
public FormulaObjPair(string k, string t, FormulaObject f) { key = k; type = t; value = f; }
public FormulaObjPair() { key = string.Empty; type = string.Empty; value = new FormulaObject(); }
public static FormulaObject operator -(FormulaObject lhs, FormulaObject rhs) { var opposite = new FormulaObject("-" + rhs.value); return(lhs + opposite); }