You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (JIRA)" <ji...@apache.org> on 2015/07/24 08:19:04 UTC
[jira] [Resolved] (JEXL-167) Possible loss of value when converting
BigDecimal to BigInteger
[ https://issues.apache.org/jira/browse/JEXL-167?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Biestro resolved JEXL-167.
--------------------------------
Resolution: Fixed
Assignee: Henri Biestro
Fix Version/s: 3.0
Use BigDecimal.toBigInteger(...) to coerce big decimal to big integer
src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
Committed revision 1692459.
> Possible loss of value when converting BigDecimal to BigInteger
> ---------------------------------------------------------------
>
> Key: JEXL-167
> URL: https://issues.apache.org/jira/browse/JEXL-167
> Project: Commons JEXL
> Issue Type: Bug
> Affects Versions: 3.0
> Reporter: Dmitri Blinov
> Assignee: Henri Biestro
> Fix For: 3.0
>
>
> In JexlArithmetic.java method *public BigInteger toBigInteger(Object val)* uses the following case for BigDecimals as for any other numbers:
> ...
> else if (val instanceof Number) {
> return BigInteger.valueOf(((Number) val).longValue());
> ...
> For large BigDecimals > Long.MAX_VALUE it may lead to loss of value. Please consider using BigDecimal.toBigInteger() method for that case?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)