<p>FYI, 5.4 (beta 2) allows you to use B and I as BigDecimal and BigInteger respectively in LHS DRL (and RHS if using MVEL) so you can write:</p>
<p>MyFact( myBigDecimal == 99.9B )</p>
<p>sent on the move</p>
<p>On 27 Mar 2012 08:16, &quot;Wolfgang Laun&quot; &lt;<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 27/03/2012, Zeke &lt;<a href="mailto:xanadu860122@gmail.com">xanadu860122@gmail.com</a>&gt; wrote:<br>
&gt; Whether the comparison is precarious or not should depend on how you handle<br>
&gt; the literal. If you handle 99.9 as BigDecimal(&quot;99.9&quot;) which precision can<br>
&gt; be controlled, you can trust the comparison.<br>
&gt;<br>
<br>
Wait a sec: primarily, you are testing a double, and this is where<br>
some unavoidable imprecision is introduced. These are some doubles<br>
close<br>
to 99.9:<br>
<br>
a     99.899999999999990000 0x1.8f99999999999p6<br>
b     99.900000000000000000 0x1.8f9999999999ap6<br>
c     99.900000000000020000 0x1.8f9999999999bp6<br>
<br>
a &lt; 99.9 is the true value truncated, b &gt; 99.9 is rounded  (the next<br>
binary digit being 1). There just isn&#39;t a double == 99.9. (Don&#39;t be<br>
confused by b&#39;s printed value.)<br>
<br>
The BigDecimal value 99.90000000000001 you have observed is due to<br>
rounding the result of new BigDecimal( (double)99.9 ), i.e.<br>
    99.900000000000005684341886080801486968994140625<br>
<br>
It&#39;s easy to see that a better value is obtained by using a String value:<br>
    new BigDecimal( &quot;99.9&quot; )<br>
but I don&#39;t know whether your Drools version would let you write<br>
doubleValue == &quot;99.9&quot;.<br>
<br>
<br>
If you want/have to stick with 4.x you might use public static final<br>
doubles defined in some Java class instead of the magic 99.9. This<br>
should avoid the sidestep into BigDecimal and the ensuing conversion<br>
confusion.<br>
<br>
-W<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>
</blockquote></p>