Hello,
As part of testing the problem from my previous posting, I noticed a
strange duplication of facts when trying to create a fact with a slot of
FLOAT type. In one case I am specifying a decimal and the other a whole
number, but the number is otherwise the same. I would think only one
fact would be created, but instead two are created but with different
float representations. The values are equal according to the =
operator; however the eq operator returns false.
Is this behavior to be expected and intended by design? I would think
the slot with type Float would automatically convert all raw values to
float and so only create one fact in the example below.
(deftemplate x "blah"
(slot num (type FLOAT)))
(defrule dupFact
?x1 <- (x (num ?num1))
?x2 <- (x (num ?num2&:(and (<> ?x1 ?x2) (= ?num1 ?num2))))
=>
(printout t "dup facts with values " ?num1 " " ?num2 crlf)
)
(reset)
(assert (x (num 1157650583.0)))
(assert (x (num 1157650583)))
(run)
(facts)
----
Jess, the Rule Engine for the Java Platform
Copyright (C) 2008 Sandia Corporation
Jess Version 7.1p2 11/5/2008
MAIN::dupFact: +1+1+2+t
==> Focus MAIN
==> f-0 (MAIN::initial-fact)
==> f-1 (MAIN::x (num 1.157650583E9))
==> f-2 (MAIN::x (num 1157650583))
==> Activation: MAIN::dupFact : f-2, f-1
==> Activation: MAIN::dupFact : f-1, f-2
FIRE 1 MAIN::dupFact f-1, f-2
dup facts with values 1.157650583E9 1157650583
FIRE 2 MAIN::dupFact f-2, f-1
dup facts with values 1157650583 1.157650583E9
<== Focus MAIN
f-0 (MAIN::initial-fact)
f-1 (MAIN::x (num 1.157650583E9))
f-2 (MAIN::x (num 1157650583))
For a total of 3 facts in module MAIN.
Thanks,
Brian