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

Osy closed JEXL-313.
--------------------
    Resolution: Implemented

Extending JexlArithmetic worked perfectly!

Indeed only overrriding *divide* , the only case identified where was required.


{code:java}
public class ExtendedJexlArithmetic extends JexlArithmetic{

        public ExtendedJexlArithmetic(boolean astrict) {
                super(astrict);
        }
        
    public Object divide(Object left, Object right)
    {
        if(left instanceof Integer && right instanceof Integer)
          return BigDecimal.valueOf((int) left).divide(BigDecimal.valueOf((int) 
right));
        return super.divide(left, right);
        
    }   

}
{code}


Thanks again [~henrib]

> Can one expression return a Float even when its elements are Integer?
> ---------------------------------------------------------------------
>
>                 Key: JEXL-313
>                 URL: https://issues.apache.org/jira/browse/JEXL-313
>             Project: Commons JEXL
>          Issue Type: Wish
>    Affects Versions: 3.1
>            Reporter: Osy
>            Priority: Minor
>
> For example a simple expression like "3/2" or another like 
> "((10/10)*(100/2)/(100*(10+1)))" are always returning an Integer result.
> But I want to maintain sme syntax without add decimal part to any number or a 
> letter to qualify the number type.
> I mean, I want to still using *"3/2"* instead "3.0/2" or "3D/2"  to get a 
> Float - or decimal - result.
> It is possible?



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to