Hi! I try to use JEXL to compute math expressions like this:
(x1-2)^4+(x1-2*x2)^2
But here is the problem - "^" mean xor, but not Math.pow() function. So, I
want to use the following code to compute a math expressions:
JexlEngine jexl = new JexlEngine();
Expression func = jexl.createExpression("(x1-2)^4+(x1-2*x2)^2");
MapContext mc = new MapContext();
mc.set("x1", 2);
mc.set("x2", 1);
System.out.println(func.evaluate(mc)); // prints "6" - WRONG ANSWER!
The question is the following. How can I use JEXL as math interpreter (so
"^" will be and Math.pow(), etc...)? Or it's impossible?