Subject: Setting precision; [Was] A puzzling arithmetic
From: Richard Fateman
Date: Sun, 16 Nov 2003 12:57:43 -0800
These two uses of FPPREC are really quite unrelated. I suggest that
there be a variable, perhaps "floatprintformat" that could be set to
a string, like "~f" for F format, or "~e" for E format, or "~7,2f" or
"~,3f" for 7 spaces, two to the right of the decimal point, or however
many spaces, three to the right of the decimal point... etc.
then instead of using (format nil "~vf" (1+ $fpprec) number)
use (format nil $floatprintformat number).
actually you might need.... (symbol-name (stripdollar
$floatprintformat)) to get
that string right in there.
I think that one can concatenate strings to compute the parts of the format
by floatprintformat:concat("~", x, "e" ). The meaning of the format stuff
is standardized in common lisp.
RJF
By the way, the maxima documentation says
Variable: FPPREC
default: [16] - Floating Point PRECision. Can be set to an integer
representing the desired precision.
the macsyma documentation says
BFPRECISION default:20
Controls the floating point precision of BIGFLOATS. Can be set to an
integer representing the desired precision.
....
There is also bfprint_precision in macsyma.
RJF
Wolfgang Jenkner wrote:
>Richard Fateman <fateman@cs.berkeley.edu> writes:
>
>
>
>>Perhaps someone is also using FPPREC for some other purpose, maybe
>>for controlling formatted output.
>>
>>
>
>Yes. EXPLODEN (in commac.lisp) passes it to FORMAT.
>
>With FPPREC:16,
>
>1. Trace: (EXPLODEN '251.7999999999999)
>2. Trace: (FORMAT 'NIL '"~vf" '17 '251.7999999999999)
>2. Trace: FORMAT ==> "251.7999999999999"
>1. Trace: EXPLODEN ==> (#\2 #\5 #\1 #\. #\7 #\9 #\9 #\9 #\9 #\9 #\9 #\9 #\9 #\9 #\9 #\9 #\9)
>
>With FPPREC:12,
>
>1. Trace: (EXPLODEN '251.7999999999999)
>2. Trace: (FORMAT 'NIL '"~vf" '13 '251.7999999999999)
>2. Trace: FORMAT ==> " 251.8"
>1. Trace: EXPLODEN ==> (#\2 #\5 #\1 #\. #\8)
>
>Should this behaviour be changed?
>
>Wolfgang
>
>_______________________________________________
>Maxima mailing list
>Maxima@www.math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima
>
>