You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sebb <se...@gmail.com> on 2009/09/14 01:37:29 UTC
[JEXL] 2.0 incompatible change of number coercion behaviour
Recent changes to the arithmetical operations mean that many
arithmetic operation results are now coerced to Integer, even if both
input variables are Long.
This is unexpected behaviour - e.g. Commons Jelly expects that Long*2 => Long
Seems to me that the result of an arithmetic op should generally be
the same as the "bigger" type, i.e the combinations should be treated
as follows:
Integer op Integer => Integer
Long op Integer|Long => Long
BigInteger op Integer|Long|Biginteger => BigInteger
BigDecimal op Integer|Long|Biginteger|BigDecimal => BigDecimal
As before, I suggest we keep:
Float|Double,anything => Double
Numeric Literals were (and are) treated as Integer, which works well
with the above scheme.
WDYT?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [JEXL] 2.0 incompatible change of number coercion behaviour
Posted by Henrib <hb...@gmail.com>.
I fixed the 'regression' (in Jelly terms); I believe this implements what you
suggest.
URL: http://svn.apache.org/viewvc?rev=814634&view=rev
Log:
When arithmetic operations are performed on 'natural' types, do not narrow
to Long if either argument is BigInteger and do not narrow to Integer if
either argument is a Long; updated JavaDoc accordingly
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/JexlArithmetic.java
--
View this message in context: http://www.nabble.com/-JEXL--2.0-incompatible-change-of-number-coercion-behaviour-tp25428428p25436003.html
Sent from the Commons - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org