Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-1878

Executable model generates BigDecimal expressions without using a MathContext

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.13.0.GA
    • 7.11.1.GA, 7.12.0.GA
    • BRE
    • False
    • False
    • Release Notes
    • ER1
    • +
    • Workaround Exists
    • Hide

      use Java dialect and specify MathContext in BigDecimal divide method appropriately.

      e.g.

          $o.setTax($price.subtract($price.divide($taxRate.add(BigDecimal.valueOf(1)), MathContext.DECIMAL128))); 
      

      Or use non-execuble model

      Show
      use Java dialect and specify MathContext in BigDecimal divide method appropriately. e.g. $o.setTax($price.subtract($price.divide($taxRate.add(BigDecimal.valueOf(1)), MathContext.DECIMAL128))); Or use non-execuble model
    • Hide

      run the attached reproducer by the script run_mvn (which is included in reproducer archive).

      Show
      run the attached reproducer by the script run_mvn (which is included in reproducer archive).
    • 2022 Week 05-07 (from Jan 31)

      Executable model generates BigDecimal expressions without using a MathContext as conversely normally done by mvel This implies that an operation like "1/3" is converted into a BigDecimal expression like

      new BigDecimal("1").divide(new BigDecimal("3"))

      causingĀ  this error

      java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.

              mfusco@redhat.com Mario Fusco
              rhn-support-hmiura Hiroko Miura
              Daniel Rosa Daniel Rosa
              Daniel Rosa Daniel Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: