[jboss-jira] [JBoss JIRA] (JBRULES-3715) when using BigDecimal Comparing to 0 only works for a certain number of time

Mario Fusco (JIRA) jira-events at lists.jboss.org
Mon Jan 14 13:20:21 EST 2013


    [ https://issues.jboss.org/browse/JBRULES-3715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12745721#comment-12745721 ] 

Mario Fusco commented on JBRULES-3715:
--------------------------------------

Considering that in Java:

new BigDecimal("0").equals(new BigDecimal("0.0"))

is false I'd actually say that it starts working only after a certain number of times.

To be more precise the constraints are evaluated in an interpreted mode (using mvel) for that "certain number of times" and after that they get jitted via ASM and run in compiled mode. The problem is that, while the jitted constraint applies the Java semantic above and correctly returns false, the interpreted (mvel) one does something slightly different and actually evaluates

new BigDecimal("0").compareTo(new BigDecimal("0.0")) == 0

that evaluates to true. 

We are still discussing which of these 2 semantics fits better the drools needs but in the meanwhile I strongly suggest to stick with the Java semantic and consider 0.0B and 0B as 2 different numbers.
                
> when using BigDecimal Comparing to 0 only works for a certain number of time
> ----------------------------------------------------------------------------
>
>                 Key: JBRULES-3715
>                 URL: https://issues.jboss.org/browse/JBRULES-3715
>             Project: JBRULES
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: All
>    Affects Versions: 5.4.0.Final
>         Environment: Jdk1.6; Drools 5.5
>            Reporter: Nicolas Heron
>            Assignee: Mario Fusco
>         Attachments: BugBigDecimalDrools.zip
>
>
> in a rule like this : 
> rule "Hello World"
>   dialect "mvel"
>   no-loop
>     when
>       $c :  Contract( aValue == 0.0B )
>     then
>        $c.setDone("OK");
>        update($c);       
> end
> when called a certain number of times, the comparaison does not work

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list