[rules-users] 'Long' and 'double' value comparing problem in drools 5.1.0

Miles Wen miles.wy.1 at gmail.com
Thu Mar 3 21:58:56 EST 2011


hi there,
I have a simple fact class:

public class Msg {
    private Long lo = 5l;
    private double dbl = 5.5;

    public Long getLo() {
        return lo;
    }

    public void setLo(Long lo) {
        this.lo = lo;
    }

    public double getDbl() {
        return dbl;
    }

    public void setDbl(double dbl) {
        this.dbl = dbl;
    }
}

and a simple drl program:

package com.sample

import com.sample.Msg;

rule "Hello World"
when
m:Msg(lo >= dbl)
then
System.out.println( "hello world" );
System.out.println(m.getLo());
System.out.println(m.getDbl());
end

I simply compare the Long value, which is 5, to the double value ,which is
5.5, with operator '>=', and the output is:

hello world
5
5.5

but it can't be ,cause 5 is less than 5.5.
then I modified the drl program a bit:

m:Msg(lo == dbl)

It successfully prints out the message as well.It seems that drools treated
the double value '5.5' as '5' in comparing...
Is this a bug or something?What could I do to correct it?
thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110304/91245c7c/attachment.html 


More information about the rules-users mailing list