Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-167

Possible loss of value when converting BigDecimal to BigInteger

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.0
    • Labels:
      None

      Description

      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?

        Attachments

          Activity

            People

            • Assignee:
              henrib Henri Biestro
              Reporter:
              dmitri_blinov Dmitri Blinov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: