thanx- i already changed it.
just a short second question:
within jess i use those double to calculate values:
for instance
(customerIndic (name flex) (value <deffunction))
the deffunction does something like (in absolute terms):
(0.9 + 0.9 + 0.6) / 3 )*1.
jess calculates 0.7999999942sth. instead of 0.8, which is probably again
because of the double. not bad at all, however it would be nicer if i could
manage to tell jess
"round the result to the 1st digit after the coma"
so it would be rounded to 0.8.
the only round -function i found would give the result 1 because thats the
closest integer.
is there another round-function or possibility already defined in jess?
tks in advance!
Ina
> Well, first of all, do realize that floating point number
> representations are finite and therefore inexact. 0.4 decimal is an
> infinite repeating fraction in binary. Although IEEE floating-point
> includes guard bits and specific machinery to deal with this, it's
> fairly easy to cause Java (or any other language) to reveal the
> round-off error in the finite representation.
>
> OK, so, look at the following line of Java code.
>
> System.out.println(String.valueOf(new Double(Float.parseFloat("0.4"))));
>
> It converts the String "0.4" into a float, constructs a double from
> that float, then converts the Double into a String and displays
> it. This line of Java -- note that this has nothing at all to do with
> Jess! -- prints "0.4000000059604645" . The problem is that the float
> has fewer significant digits than the double, so the lower accuracy
> float shows up as the "...59604645" digits in the double.
>
> If, on the other hand, you do this:
>
> System.out.println(String.valueOf(Double.parseDouble("0.4")));
>
> this line prints "0.4", as you'd expect.
>
> Now, the Value constructor you're calling takes a double as an
> argument, not a float, so what your code is doing below is very like
> the first example: parse into a float, then convert to a double. Just
> use double instead, and your "problem" should go away:
>
> fInfo.setSlotValue("certainty", new
> Value(Double.parseDouble((String) info.elementAt(2)), RU.FLOAT));
>
>
> I think Ina Sollinger wrote:
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
> > hi all,
> >
> > iam having a very "strange" problem:
> >
> > iam parsing values from java to jess by using:
> >
> > fInfo.setSlotValue("certainty", new
> > Value(Float.parseFloat((String)info.elementAt(2)), RU.FLOAT));
> >
> > the info-vektor is a string vector, sometimes elements of the string are
> > floats, therefore i chose the method Float.parseFloat.
> >
> > public Vector getInfo(String info){
> > Vector v = new Vector();
> > }else if(info.equals("occupation")){
> > v.addElement(info);
> > v.addElement("beamter");
> > v.addElement("0.4"); /*<- (String)info.elementAt(2)
> > v.addElement("");
> > v.addElement("");
> > v.addElement("");
> >
> > in jess the facts are "right" as long as info.elementAt(2) is 1, 0.5 or
> 0.
> > However, if it is
> > 0.4 (as in the example above) the fact in jess is 0.40000000596...
> > or if it is 0.9 in the vector it becomes 0.89999999761 in Jess ?? !
> >
> > Can someone explain this behaviour?
> > i really tried to change the 0.4 to 0.5 and it worked fine, but when i
> > change the same number to something not 0.5 or 1 again, the values in
> jess become
> > akward.???
> >
> > TKS,
> >
> > Ina
> >
> > --
> > +++ GMX - Mail, Messaging & more http://www.gmx.net +++
> > NEU: Mit GMX ins Internet. Rund um die Uhr f|r 1 ct/ Min. surfen!
> >
> > --------------------------------------------------------------------
> > To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> > in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> > (use your own address!) List problems? Notify
> [EMAIL PROTECTED]
> > --------------------------------------------------------------------
> >
>
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Distributed Systems Research Phone: (925) 294-2154
> Sandia National Labs FAX: (925) 294-2234
> Org. 8920, MS 9012 [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
> (use your own address!) List problems? Notify [EMAIL PROTECTED]
> --------------------------------------------------------------------
>
--
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr f|r 1 ct/ Min. surfen!
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------