javascript - Unable to evaluate math expressions using Mathos Math Prser -
I am using to evaluate math expressions. I am trying to parse the following expression, but it throws the FormatException - Input string not in the correct format.
Mathos.Parser.MathParser parser = new Mathos.Parser.MathParser (); String expression = "mathpaw ((4), (5))"; // or "Math.sqrt (1)"; String result = parser. Purse (expression); ostring ();
In my app, I am using the math editor, which gives me the math. Using this math I am parsing it for plain math expression using javascript and then sending this expression to evaluate my C # code. What's wrong with my expression?
Note: Due to certain conditions I am not evaluating math expression in JavaScript.
The reason for this does not work because the pow Is defined as. The code below should work:
Mathos. Parser Mathpresar parser = new mathos. Parser MathPerson (); String expression = "pau (4,5)"; String result = parser. Purse (expression); ostring (); // or string expression = 2 = "4 ^ 5"; String result2 = parser.Parse (expression2). Ostring (); Assurance First (result, result 2);
Basically, to use the Math.Po function, you build in the power operator or made in the power function .
You can change the definition of power function at any time. The current definition is:
- Power function:
local function.add ("pau", x => (decimal) math.p. ((double) x [0], (bi ) X [1]));
- Power operator:
operator list.ad ("^");
andoperator action.ed ("^", (number A, number B) => (decimal) math.po ((double) number A, (double) number b));
Comments
Post a Comment