The long answer to your question can be found in <a href="http://en.wikipedia.org/wiki/Floating_point">http://en.wikipedia.org/wiki/Floating_point</a>.<br><br>The short answer is that machine numbers for floats and doubles are approximations to almost all rational numbers, or, if you prefer, fractions. This is because most numbers have infinite binary expansions (such as 1/3 in decimal).<br>
<br>Even when you use &quot;99.9&quot; in one place (a Java program), there&#39;s no guarantee that the double produced by the Java compiler is equal to the double resulting from the same literal via Drools&#39; compiler chain (in a DRL file). Conversion between double and float is guaranteed to generate inequality for such numbers.<br>
<br>For your tests you might try a fraction that can be represented accurately, e.g., 0.5 or 0.125.<br><br>-W<br><br><br><div class="gmail_quote">2009/4/21 Zeke <span dir="ltr">&lt;<a href="mailto:xanadu860122@gmail.com">xanadu860122@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi, All:<br>  My drl file is like below:<br>  package org.drools.examples;<br> <br>  import org.drools.examples.HelloWorldExample.Message;<br>
<br>  rule &quot;check deep int&quot;<br>      dialect &quot;java&quot;<br>      when<br>
          m:Message( sec.fir.d == &quot;99.9&quot; )<br>      then<br>          System.out.println( &quot;===check deep double ok===&quot; ); <br>  end<br> <br>  I find that &quot;==&quot; 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 &lt; &quot;100&quot; or sec.fir.d &gt; &quot;99.8&quot;, it works well. Is it a bug?<br>

<br>  I attach my test code. And I add below jars into classpath:<br>  antlr-runtime-3.0.jar<br>  core-3.2.3.v_686_R32x.jar<br>  drools-compiler-4.0.7.jar<br>  drools-core-4.0.7.jar<br>  drools-decisiontables-4.0.7.jar<br>

  drools-jsr94-4.0.7.jar<br>  janino-2.5.10.jar<br>  jsr94-1.1.jar<br>  mvel-1.3.12-java1.5.0.jar<br><br>  Can anyone kindly help me?<br><br>Thanks!<br><font color="#888888">- Zeke<br> 
</font><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>