commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Biestro (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (JEXL-87) Inconsistent behaviour of arithmetical operations
Date Wed, 02 Sep 2009 14:20:32 GMT

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

Henri Biestro resolved JEXL-87.
-------------------------------

    Resolution: Fixed

JEXL-87: 
Fix in Parser.jjt, "x + y / a + b" was throwing a ParseException 
Fixed JexlArithmetic; use the same algo wrt datatype for all operations, fixed modulo for
BigDecimal and made integer results to scale down to 'int' (was only to long) when possible

Fixed tests to check for 'int(eger)' instead of 'long' when needed. 

Modified: 
    commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/JexlArithmetic.java

    commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt

    commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java

    commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ForEachTest.java

    commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/IssuesTest.java

    commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/JexlTest.java 
    commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ScriptTest.java

    commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/WhileTest.java


> Inconsistent behaviour of arithmetical operations
> -------------------------------------------------
>
>                 Key: JEXL-87
>                 URL: https://issues.apache.org/jira/browse/JEXL-87
>             Project: Commons JEXL
>          Issue Type: Bug
>            Reporter: Sebb
>            Assignee: Henri Biestro
>             Fix For: 2.0
>
>
> BigInteger(7) / BigInteger(2) == 3
> whereas
> BigDecimal(7) / BigDecimal(2) == 4, because the result is rounded up.
> I would expect the results to be the same.
> Rather worse is:
> BigDecimal(7) % BigDecimal(2) == -1
> which makes no sense at all.
> Seems to me that the arithmetic "rules" need revisiting and rationalising - for example
why should Integer be treated as double?
> At present literal numbers are treated as Integer or Float; there's no option to generate
Long or Double literals.

-- 
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