Subject: get fpprintprec to round float inside function?
From: Edwin Woollett
Date: Fri, 1 Jul 2011 10:40:51 -0700
On June 30, 2011, Richard Fateman wrote:
--------------------------
>I think you can do this:
>folder_info(path):=
> block([fpprecprint:2],
> display ( folder_info1(path)))
--------------------
This method avoids introducing an extraneous global variable,
but the output (with fpprecprint --> fpprintprec (!) ) still has the
display command exhibited on the left hand side (although we
get correct rounding).
I have decided to abandon producing a list, and instead accept a
series of line outputs, most simply produced by using print,
although one could get fancier with formated output via
printf.
With the code:
------------------
folder_info (path):=
block([fpprintprec:2,vp],
for vp in folder_info1 (path) do
apply ('print,vp))$
----------------------
the output is correctly rounded and looks like:
----------------------
(%i3) folder_info ("c:/work2/temp1/");
atext1.txt 6 0.2
atext2.txt 7 0.2
calc1news.txt 116 4.2
ndata1.dat 9 0.3
stavros-tricks.txt 44 1.4
text1.txt 5 0.2
text2.txt 5 0.2
trigsimplification.txt 157 5.0
wu-d.txt 4 0.3
(%o3) done
--------------------------------------
displaying name, number of lines, and KB.
Ted Woollett