[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-user
Subject:    Re: [jexl] Make jexl consider power operator
From:       aisen faith marrero <faith14bunso () gmail ! com>
Date:       2020-09-23 22:44:32
Message-ID: A7DAE906-39EC-4E8F-9B53-696B17B74526 () gmail ! com
[Download RAW message or body]

Thanks a million for... !

Sent from my iPhone

> On Sep 23, 2020, at 7:28 AM, BENGUIGUI Michael \
> <michael.benguigui@irt-saintexupery.com> wrote: 
> Dear all,
> 
> I am trying to evaluate the following expression via jexl :  x^y
> What I've tried, is to extend JexlArithmetic:
> 
> // Extend Arithmetic
> public class ExtendedJexlArithmetic extends JexlArithmetic
> {
> public ExtendedJexlArithmetic(boolean strict){
> super(strict);
> }
> 
> public xor(Object l, Object r){
> return Math.pow(l, r);
> }
> }
> 
> def engine = new JexlBuilder().cache(512).strict(true).silent(false).namespaces(ns).arithmetic(new \
> ExtendedJexlArithmetic(true)).create(); \
> engine.createExpression(model_formula).evaluate(contextMap); 
> 
> However, it does not consider operator priority. As a result, I am still getting \
> wrong results: 
> 2+4^3 -> 216 (instead of 66).
> 
> How can I properly fix this ?
> 
> Thhhx!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic