I think Ina Sollinger wrote:
> 
> (0.9 + 0.9 + 0.6) / 3 )*1.
> 
> jess calculates 0.7999999942sth. instead of 0.8,

Again, 0.8 can't be precisely represented as a floating point number.

> 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.
> 

Note that Java *can't* "round 0.7999999942 to 0.8", because 0.8 simply
can't be represented exactly as a floating-point number. What it *can*
do, however, is render a number as a string, accurate to a specific
number of decimal places -- not the same as rounding. Jess offers the
(format) function which can produce floating-point numbers formatted
to your specifications. For example, the function call

  (format nil "%.2f" 0.9999)

returns the string "1.00".




---------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to