<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 27/03/2012 03:01, Zeke wrote:
    <blockquote
cite="mid:CAOrFVxbX2zd9PEuP4QmGFDW6N4+JmoZbnyuRHEcJNW14zdcEpw@mail.gmail.com"
      type="cite">Whether the comparison is precarious or not should
      depend on how you handle the literal. If you handle 99.9 as
      BigDecimal("99.9") which precision can be controlled, you can
      trust the comparison.<br>
      <br>
      Anyway, since it has different behavior for these two cases, it
      should be a bug, right? I just want to know it is Drools' bug or
      MVEL's... If it is MVEL's, I may need ask for MVEL guys' help...<br>
    </blockquote>
    If you need this fixed, you'll need to move to Drools 5.3.<br>
    <br>
    Mark<br>
    <blockquote
cite="mid:CAOrFVxbX2zd9PEuP4QmGFDW6N4+JmoZbnyuRHEcJNW14zdcEpw@mail.gmail.com"
      type="cite">
      <br>
      <div class="gmail_quote">On 26 March 2012 19:50, Wolfgang Laun <span
          dir="ltr">&lt;<a moz-do-not-send="true"
            href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          4.0.7 is rather old. 5.1.1 and later do not exhibit this
          behaviour.<br>
          <br>
          However, it should be noted that comparing double values using
          == is a<br>
          precarious approach. For instance, 99.9 (the mathematical
          number)<br>
          cannot be represented as a double machine number. Hence, you
          do not<br>
          truly test for<br>
          equality with that number, just with its approximation by some
          machine<br>
          number.<br>
          <br>
          -W<br>
          <div class="im"><br>
            On 26/03/2012, Zeke &lt;<a moz-do-not-send="true"
              href="mailto:xanadu860122@gmail.com">xanadu860122@gmail.com</a>&gt;
            wrote:<br>
            &gt; Hi, guys:<br>
            &gt; &nbsp; I am using Drools 4.0.7. I find a strange behavior.
            When my LHS is<br>
            &gt; "Message( varDouble == 99.9 )" and "varDouble" equals
            "new Double(99.9)",<br>
            &gt; the condition is true. But when my LHS is "Message(
            types.doubleType ==<br>
            &gt; 99.9 )" and the "doubleType" field is also equal to
            "new Double(99.9)", the<br>
            &gt; condition is false. I debug the code, and find that:<br>
            &gt;<br>
            &gt; &nbsp; When the LHS is "Message( varDouble == 99.9 )", the
            logic will handle the<br>
          </div>
          &gt; literal 99.9 as *Double.valueOf( &#8220;99.9&#8221; )*, and the
          comparison is between<br>
          &gt; *(new<br>
          &gt; Double(99.9)).doubleValue(*) and *Double.valueOf( &#8220;99.9&#8221;
          ).doubleValue()*,<br>
          <div class="im">&gt; &nbsp; When the LHS is "Message(
            types.doubleType == 99.9 )", the logic is<br>
          </div>
          &gt; different from above. The comparison is between *new
          BigDecimal((Double)<br>
          &gt; 99.9, MathContext.DECIMAL64)* (which double value is
          99.90000000000001) and<br>
          &gt; *new BigDecimal(&#8220;99.9&#8221;, MathContext.DECIMAL64)* (which
          double value is<br>
          <div class="im">&gt; 99.9).<br>
            &gt;<br>
            &gt; &nbsp; I think we need make things consistent. "varDouble"
            and<br>
            &gt; "types.doubleType" are of the same type and value. It
            doesn't make sense to<br>
            &gt; have different behavior just because of one field is
            nesting while the<br>
            &gt; other is not. &nbsp;I know Drools is using MVEL to evaluate
            the condition. But I<br>
            &gt; am not sure it is a MVEL bug or Drools uses MVEL wrong.
            It will be much<br>
            &gt; appreciated if you can give me any comments!<br>
            &gt;<br>
            <br>
          </div>
          _______________________________________________<br>
          rules-users mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
          <a moz-do-not-send="true"
            href="https://lists.jboss.org/mailman/listinfo/rules-users"
            target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
        </blockquote>
      </div>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>