Well,  I think the best thing to do is for you to upgrade to the
newest version of Jess and see if your problem goes away. I dug out an
archive of the final version of 4.1 (which went out with a
version-string reading 4.1b6) and tried your rule - it works OK for me
with both integral and floating point negative numbers:

c:/temp/Jess41> java jess.Main

Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 4.1b6 8/20/98

Jess> (defrule set_abs
(number ?num&:(< ?num 0))
=>
 (assert (abs_num (abs ?num)))
)
TRUE
Jess> (assert (number -1))
<Fact-0>
Jess> (run)
TRUE
Jess> (facts)
f-0   (number -1)
f-1   (abs_num 1)
For a total of 2 facts.
TRUE
Jess> (assert (number -1.0))
<Fact-2>
Jess> (run)
TRUE
Jess> (facts)
f-0   (number -1)
f-1   (abs_num 1)
f-2   (number -1.0)
f-3   (abs_num 1.0)
For a total of 4 facts.
TRUE

I think Christo Andonyadis wrote:
> 
> Where ?b is a negative integer,
> the error I get on the (abs ?b) call is:
> Rete Exception in routine Value::Value while executing defrule
> set_abs_et.
>   Message: not a float type: type = 0 at line 0:  ( run ) .
> 
> the error I get on the (- ?a ?b)  is:
> Rete Exception in routine Value::Value while executing defrule
> time_between.
>   Message: not a float type: type = 4 at line 0:  ( run ) .
> 
> I was hoping I had the syntax wrong. 
> There is no problem using the "+" operator with negative numbers, 
> only the "-" and apparently the abs function. 
> The fact that (+ ?a ?b) where ?b is negative works but that (- ?a ?b)
> does not 
> made me think that it was a bug in Jess.
> If I don't use varaibles the minus works i.e. (- 10 -5) gives 15.
> 
> Thanks
> Christo
> 
> Dr. Ernest J. Friedman-Hill wrote:
> > 
> > I think Christo Andonyadis wrote:
> > >
> > > I'm using Jess 4.1.
> > > I get an error when trying to use the "-" operator with negative
> > > numbers.
> > > Is this a bug?
> > 
> > Hard to say. WHat error do you get?
> > 
> > >
> > > To work around this problem, I am trying to use the abs function to
> > > convert the negative number to a positive.
> > >
> > > What is wrong with this rule?
> > > (defrule set_abs
> > >       (number ?num&:(< ?num 0))
> > >       =>
> > >       (assert (abs_num (abs ?num)))
> > > )
> > 
> > I don't know. Looks fine to me. Does it cause a problem?
> > 
> > Note that some JVMs have faulty versions of the stream tokenization
> > classes that older versions of Jess used to use (4.1 counts as older,
> > I think.) These faults could cause problems in parsing negative
> > numbers and the minus operator. Later versions of Jess work around
> > these problems by not using these classes. You could try upgrading
> > your JVM if it's an old one.


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9214                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to