[rules-users] Double Handling

Wolfgang Laun wolfgang.laun at gmail.com
Mon Apr 12 09:30:08 EDT 2010


Well, then drop the
  dialect "mvel"
and write the pattern as
   $d : IndividualDecision( loanToVal < 85.0 )

There's no visible need to use mvel.

Or eval: the simplest form for constraints is always best.

-W



2010/4/12 Ade Timi <adeyinka.timi at nathean.com>

>  Many thanks for the response!
>
> Yes it fires when I use 85.0 instead, but it obviously shouldn’t as the
> condition is false. My code now looks like this:
>
>
>
> *rule* "G2 Equity in Asset"
>
>       *ruleflow-group* "goods"
>
>       *dialect* "mvel"
>
>       *when*
>
>             $d : IndividualDecision(*eval*($d.getLoanToValue() < 85.0))
>
>       *then*
>
>             $d.setGoodCount($d.incGoodCount());
>
>             $d.setMessage("0065: G2: Good: Good Equity in Deal");
>
>             //System.out.println((Double.valueOf("85")).doubleValue());
>
>             System.out.println("loanToValue: " + ($d.getLoanToValue()));
>
> *end*
>
>
>
> I still get the print output of 92000.0, which is as I expect but I don’t
> expect the rule to be fired at all. The weird thing is that when I change
> the condition to ‘>’ which is the true condition it never fires! I’m at a
> loss as to why this is happening.
>
>
>
> - Ade
>
>
>  ------------------------------
>
> *From:* rules-users-bounces at lists.jboss.org [mailto:
> rules-users-bounces at lists.jboss.org] *On Behalf Of *Wolfgang Laun
> *Sent:* 11 April 2010 09:11
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Double Handling
>
>
>
> You are comparing a double to a String ("85"). Although MVEL might convert
> strings to numbers, I wouldn't use this without some cogent reason.
>
> Do you have this unexpected firing also when you use a double literal,
> i.e., 85.0 ?
>
> -W
>
>  2010/4/9 Ade Timi <adeyinka.timi at nathean.com>
>
> Hi,
>
>
>
> I am new to Drools. I am having a problem comparing 2 double values. I have
> a Java class with a double attribute called loanToValue. The loanToValue is
> been read from an XML file and the value is 92000.0. Based on this value I
> do not expect this rule to be fired, but for some reason it does. And the
> print statement returns 92000.0. Does anyone know what I’m doing wrong? My
> rule looks as follows:
>
>
>
> *rule* "G2 Equity in Asset"
>
>       *ruleflow-group* "goods"
>
>       *dialect* "mvel"
>
>       *when*
>
>             $d : IndividualDecision()
>
>             Individual(*eval*($d.getLoanToValue() < "85"))
>
>       *then*
>
>             System.out.println("loanToValue: " + ($d.getLoanToValue()));
>
> *end*
>
> * *
>
> Thanks,
>
> Ade
>
>
>
> *Adeyinka Timi* | Technical Supprt | *Nathean Technologies Ltd*
>
> Registered Office 3 Lyncon Court, IDA Science & Technology Park,
> Snugborough Road, Blanchardstown, Dublin 15, Ireland
> *T +353 1 685 3001* | VOIP 076 615 1117 | *E adeyinka.timi at nathean.com* |
> <http://www.nathean.com/>www.nathean.com
>
> Incorporated in Ireland, No. 339972
>
> The information appearing in this email and any files transmitted with it
> is confidential and may not be reproduced, modified, distributed,
> transmitted, displayed, published or broadcast without the prior written
> permission of Nathean Technologies Ltd. It is intended solely for the use of
> the addressee(s). Nathean Technologies Ltd, its directors, officers and
> employees do not accept liability for any loss or damage of any nature
> howsoever arising pertaining to the use of information appearing in this
> email and/or any files transmitted with it. Whilst this email has been
> checked for the presence of computer viruses, Nathean Technologies Ltd does
> not, except as required by law, represent, warrant and/or guarantee that the
> integrity of this communication has been maintained nor that the
> communication is free of errors, viruses, interception or interference.
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100412/8713c1ae/attachment.html 


More information about the rules-users mailing list