[ 
https://issues.apache.org/jira/browse/JEXL-172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Henri Biestro resolved JEXL-172.
--------------------------------
    Resolution: Not A Problem

When all operands are integers, the operation is performed on integers without 
conversion. In this case (1 / 100) returns 0 and 1 / 0 throws an exception in 
strict mode.
The workaround is to use 'doubles' in you expression like: (1 / (1.0 / 100))  
Or you can derive JexlArithmetic and overload (at least) the divide method.

> Unexpected divide error for numerator which contains division in strict mode
> ----------------------------------------------------------------------------
>
>                 Key: JEXL-172
>                 URL: https://issues.apache.org/jira/browse/JEXL-172
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 2.1.1
>         Environment: Java 7 OpenJDK
>            Reporter: Lars Helge Ă˜verland
>            Priority: Minor
>
> It seems that evaluating expressions which contains nested divisions causes 
> an exception to be thrown with cause "divide error".
> The following expression is valid math and should return 100:
> 1 / (1 / 100)
> Instead it throws:
> org.apache.commons.jexl2.JexlException: 
> org.hisp.dhis.commons.util.ExpressionUtils.evaluate@81![0,13]: '1 / (1 / 
> 100);' divide error
> This only applies to strict mode. However it could be argued that this should 
> pass even in strict mode.
> I could not find anything in the docs about this so please excuse me if I 
> missed something.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to