Thank you very much.


[EMAIL PROTECTED] wrote:
I think Holly wrote:
> Hello,
>
> How can I reduce the number of significant digits in the result of a function? The equation I used gives a 17-decimal digit answer. I only need 4.
>

To be clear, you don't want to actually reduce the number of
significant digits in the number; you want to limit the number of
digits that are displayed. The "printout" function uses Java's default
Double.valueOf() function, and so you see many, many digits. Instead
of printout (or in addition to printout) you can use "format":

Jess> (printout t (pi) crlf)
3.141592653589793
Jess> (format nil "%.4f" (pi))
"3.1416"
Jess>

The first argument to "format" is a router to which the output should be
sent, or "nil" to just return the formatted data; and the second
argument is a format specifier using the same syntax as AN! SI C's
"printf" function. "%.4f" means a floating-point number with 4 decimal
places.




Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.

Reply via email to