ezylang / EvalEx

EvalEx is a handy expression evaluator for Java, that allows to evaluate simple mathematical and boolean expressions.
https://ezylang.github.io/EvalEx/
Apache License 2.0
991 stars 270 forks source link

Broken boolean expression evaluation in version 3.1.0 #435

Closed Adler95 closed 8 months ago

Adler95 commented 8 months ago

With version 3.1.0, the boolean expression evaluation was broken. It seems that the problem takes effect only when scale of the BigDecimal is greater than zero.

Example (correct result) with scale 0:

        Expression expression = new Expression("a && b");

        EvaluationValue result = expression
                .with("a", BigDecimal.ZERO)
                .and("b", BigDecimal.ZERO)
                .evaluate();

        System.out.println(result.getBooleanValue()); // prints false

Example (wrong result) with scale 1:

        Expression expression = new Expression("a && b");

        EvaluationValue result = expression
                .with("a", new BigDecimal("0.0"))
                .and("b", new BigDecimal("0.0"))
                .evaluate();

        System.out.println(result.getBooleanValue()); // prints true