commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dion gillard (JIRA)" <j...@apache.org>
Subject [jira] Updated: (JEXL-30) ASTAddNode does not add BigDecimal objects correctly
Date Fri, 26 Oct 2007 08:53:51 GMT

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

dion gillard updated JEXL-30:
-----------------------------

    Fix Version/s: 2.0

> ASTAddNode does not add BigDecimal objects correctly
> ----------------------------------------------------
>
>                 Key: JEXL-30
>                 URL: https://issues.apache.org/jira/browse/JEXL-30
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 1.1
>         Environment: All
>            Reporter: Curtis Stanford
>             Fix For: 2.0
>
>
> 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.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message