commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Dorsey <Jason.Dor...@netiq.com>
Subject RE: [jexl]
Date Mon, 09 Apr 2012 15:01:10 GMT
From what  I am seeing below this come out to :

"2.3 multiplied by 325 divided by 100"		Or 		"2.3 * 3.25"

And that does equal your result.

I think you should be multiplying by 0.023 instead of 2.3.

Jason Dorsey | Engineering Intern
1233 West Loop South
Houston, TX 77027 USA
Jason.Dorsey@netiq.com 
www.attachmate.com  |  www.netiq.com

-----Original Message-----
From: Даниил [mailto:danilkus@gmail.com] 
Sent: Monday, April 09, 2012 2:53 AM
To: user@commons.apache.org
Subject: [jexl]

I'm trying to evaluate the expression 2.3% of value and I got invalid 
result:

My code is follow:
        BigDecimal bd = new BigDecimal("325");

        JexlEngine jexl = new JexlEngine();

        String expr = "2.3*SO/100";
       
        JexlContext jc = new MapContext();
        jc.set("SO", bd);
       
        Object evaluate = jexl.createExpression(expr).evaluate(jc);
        System.out.println(evaluate);

produce the result: 7.474999999999999 which is incorrect.



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

Mime
View raw message