[ http://issues.apache.org/jira/browse/JEXL-30?page=comments#action_12451176 ] Rahul Akolkar commented on JEXL-30: -----------------------------------
I agree, Dion. We probably want to fold in similar changes accounting for BigIntegers into this ticket. > ASTAddNode does not add BigDecimal objects correctly > ---------------------------------------------------- > > Key: JEXL-30 > URL: http://issues.apache.org/jira/browse/JEXL-30 > Project: Commons JEXL > Issue Type: Bug > Affects Versions: 1.1 > Environment: All > Reporter: Curtis Stanford > > The ASTAddNode only checks for Float or Double objects when adding floating > point numbers. If the objects are not Float or Double, they are added as > Long's. As a result, adding BigDecimal objects loses any existing decimal > points. > Untested patch: > Index: ASTAddNode.java > =================================================================== > --- ASTAddNode.java (revision 476204) > +++ ASTAddNode.java (working copy) > @@ -16,6 +16,8 @@ > > package org.apache.commons.jexl.parser; > > +import java.math.BigDecimal; > + > import org.apache.commons.jexl.JexlContext; > import org.apache.commons.jexl.util.Coercion; > > @@ -71,8 +73,8 @@ > * if anything is float, double or string with ( "." | "E" | "e") > * coerce all to doubles and do it > */ > - if (left instanceof Float || left instanceof Double > - || right instanceof Float || right instanceof Double > + if (left instanceof Float || left instanceof Double || left > instanceof BigDecimal > + || right instanceof Float || right instanceof Double || right > instanceof BigDecimal > || (left instanceof String > && (((String) left).indexOf(".") != -1 > || ((String) left).indexOf("e") != -1 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]