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

            return(lhs + opposite);
        }