commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Curtis Stanford (JIRA)" <j...@apache.org>
Subject [jira] Created: (JEXL-30) ASTAddNode does not add BigDecimal objects correctly
Date Fri, 17 Nov 2006 16:55:38 GMT
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message