Esempio n. 1
0
        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()));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public FormulaObject Log(FormulaObject obj)
 {
     obj = new FormulaObject("1.0") / obj;
     return(Pow(obj));
 }
Esempio n. 4
0
 public FormulaObjPair(string k, string t, FormulaObject f)
 {
     key   = k;
     type  = t;
     value = f;
 }
Esempio n. 5
0
 public FormulaObjPair()
 {
     key   = string.Empty;
     type  = string.Empty;
     value = new FormulaObject();
 }
Esempio n. 6
0
        public static FormulaObject operator -(FormulaObject lhs, FormulaObject rhs)
        {
            var opposite = new FormulaObject("-" + rhs.value);

            return(lhs + opposite);
        }