[rules-users] "==" operator does not work on float and double type

Zeke xanadu860122 at gmail.com
Tue Apr 21 03:56:57 EDT 2009


Hi, All:
  My drl file is like below:
  package org.drools.examples;

  import org.drools.examples.HelloWorldExample.Message;

  rule "check deep int"
      dialect "java"
      when
          m:Message( sec.fir.d == "99.9" )
      then
          System.out.println( "===check deep double ok===" );
  end

  I find that "==" operator does not work well on double and float type.
This condition can not be satisfied. If I change the condition to sec.fir.d
< "100" or sec.fir.d > "99.8", it works well. Is it a bug?

  I attach my test code. And I add below jars into classpath:
  antlr-runtime-3.0.jar
  core-3.2.3.v_686_R32x.jar
  drools-compiler-4.0.7.jar
  drools-core-4.0.7.jar
  drools-decisiontables-4.0.7.jar
  drools-jsr94-4.0.7.jar
  janino-2.5.10.jar
  jsr94-1.1.jar
  mvel-1.3.12-java1.5.0.jar

  Can anyone kindly help me?

Thanks!
- Zeke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090421/e687f4c3/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HelloWorldExample.java
Type: application/octet-stream
Size: 4417 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20090421/e687f4c3/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.drl
Type: application/octet-stream
Size: 242 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20090421/e687f4c3/attachment-0001.obj 


More information about the rules-users mailing list