Exemplo n.º 1
0
        public CalcNumber apply_exp_operation(CalcNumber a, CalcNumber b, CalcOperator op)
        {
            // application of exp, log and root operations

            CalcNumber rtn;

            switch (op.get_operator())
            {
            case "^":
                rtn = new CalcNumber(Math.Pow(a.get_double(), b.get_double()));
                break;

            case "log":
                rtn = new CalcNumber(Math.Log(a.get_double(), b.get_double()));
                break;

            case "root":
                rtn = new CalcNumber(Math.Pow(a.get_double(), 1.0 / b.get_double()));
                break;

            default:
                rtn = new CalcNumber();
                break;
            }

            return(rtn);
        }
Exemplo n.º 2
0
        public CalcNumber apply_line_operation(CalcNumber a, CalcNumber b, CalcOperator o)
        {
            CalcNumber returnvalue;

            switch (o.get_operator())
            {
            case "-":
                returnvalue = new CalcNumber(a.get_double() - b.get_double());
                break;

            case "+":
                returnvalue = new CalcNumber(a.get_double() + b.get_double());
                break;

            default:
                returnvalue = new CalcNumber();
                break;
            }
            return(returnvalue);
        }
Exemplo n.º 3
0
        public CalcNumber apply_point_operation(CalcNumber a, CalcNumber b, CalcOperator o)
        {
            CalcNumber returnvalue;

            switch (o.get_operator())
            {
            case "*":
                returnvalue = new CalcNumber(a.get_double() * b.get_double());
                break;

            case "/":
                returnvalue = new CalcNumber(a.get_double() / b.get_double());
                break;

            default:
                returnvalue = new CalcNumber();
                break;
            }

            return(returnvalue);
        }