ArithmeticException (Non-terminating decimal expansion) occurs in the executable model.

Solution Unverified - Updated -


In executable model, running rules written in MVEL dialect and containing a divide operation of BigDecimal values whose exact quotient has a nonterminating decimal expansion (e.g. 1/3 is 0.3333..., 10/11 is 0.9090...) causes ArithmeticException (Non-terminating decimal expansion).

For example, when running a rule like (*1) by giving a Fact object where value1 property is BigDecimal("1") and value2 is BigDecimal("3") in non-executable model, I can get a result like (*2) successfully.


rule "Rule 1"
    dialect "mvel"
        $fact : Fact( $value1 : value1, $value2 : value2 )
        $fact.result = $value1 / $value2;
        System.out.println("Action of Rule 1: " + $fact);
// value1 and value2 are BigDecimal-type properties of Fact class.


Action of Rule 1: com.example.reproducer.Fact[value1=1,value2=3,result=0.3333333333333333333333333333333333]

On the other hand, when running the same thing in executable model, the execution fails due to ArithmeticException like (*3) below.


Exception executing consequence for rule "Rule 1" in com.example.reproducer: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
    at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(
    at org.drools.core.common.DefaultAgenda.handleException(
    at org.drools.core.phreak.RuleExecutor.innerFireActivation(
    at org.drools.core.phreak.RuleExecutor.fireActivation(
    at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(
    at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(
    at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(
    at org.drools.core.common.DefaultAgenda.fireLoop(
    at org.drools.core.common.DefaultAgenda.internalFireAllRules(
    at org.drools.core.common.DefaultAgenda.fireAllRules(
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(
    at com.example.reproducer.DroolsTest.main(
Caused by: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
    at java.base/java.math.BigDecimal.divide(
    at com.example.reproducer.P9E.LambdaConsequence9ED3D482DC0FFF72FA6A4480D1D7551F.execute(
    at com.example.reproducer.P9E.LambdaConsequence9ED3D482DC0FFF72FA6A4480D1D7551F.execute(
    at org.drools.model.functions.Block3$Impl.execute(
    at org.drools.modelcompiler.consequence.LambdaConsequence.evaluate(
    at org.drools.core.phreak.RuleExecutor.innerFireActivation(
    ... 12 more


  • Red Hat Decision Manager (RHDM)
    • 7.10.0 - 7.12.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content