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] [Commented] (JEXL-143) Huge numbers are rounded
Date Sun, 27 Oct 2013 17:08:31 GMT

    [ https://issues.apache.org/jira/browse/JEXL-143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13806385#comment-13806385
] 

Henri Biestro commented on JEXL-143:
------------------------------------

I'll assume you are using java.util.Math as namespace for math: ; the pow function signature
is 'double pow(double, double)' .
The result you get is (unfortunately in your case) what is expected.
To get the behavior you desire, you'll have to create your own 'math' class namespace and
implement the methods as you see fit.

As a side note, the '^' operator in Jexl is expected to behave as a bitwise-xor, not an exponentiation;
and the '<<' operator is not supported.


> Huge numbers are rounded 
> -------------------------
>
>                 Key: JEXL-143
>                 URL: https://issues.apache.org/jira/browse/JEXL-143
>             Project: Commons JEXL
>          Issue Type: Improvement
>    Affects Versions: 2.1.1
>         Environment: Ubunu 12.04, android studio 0.2.10
>            Reporter: Frank
>
> When calculating huge numbers, which are still in the long range the result is wrong
(or getting rounded somehow), e.g.
> Expression e = jexl.createExpression("math:pow(2, 62)"); //also tried `pow(2.0, 62.0)`
and pow(2L, 62L)`
> JexlContext context = new MapContext();
> String res = String.valueOf(e.evaluate(context));
> returns `4611686018427388000` but it should be `4611686018427387904`



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message