Subject: get fpprintprec to round float inside function?
From: Edwin Woollett
Date: Thu, 30 Jun 2011 13:24:46 -0700
I would like to use fpprintprec (or is there another
way?) to round bytes to KB inside a function
folder_info, using code like:
----------------------------------
folder_info ( %fnamec ) :=
block ( [ %vb, %afL, fpprintprec : 2,
%rbL : [], %fiL ],
display (fpprintprec),
%afL : ls (%fnamec),
for %vb in %afL do
( %fiL : file_info ( %vb ),
%rbL : cons ( [ scut ( %vb ),
part ( %fiL, 2),
float ( part ( %fiL, 4)/1000 ) ],
%rbL)),
reverse (%rbL))$
----------------------------------
The fourth element of the list returned by
file_info is the number of bytes in the
file ( gotten from flength after using
openr).
The indicated display of the local value of
fpprintprec is 2 but no float rounding
occurs.
---------------------------------------------
(%i1) load(search_mfiles);
(%o1) c:/work2/search_mfiles.mac
(%i2) folder_info ("c:/work2/temp1/");
fpprintprec = 2
(%o2) [[atext1.txt, 6, 0.154], [atext2.txt, 7, 0.156],
[calc1news.txt, 116, 4.187], [ndata1.dat, 9, 0.336],
[stavros-tricks.txt, 44, 1.424], [text1.txt, 5, 0.152], [text2.txt, 5,
0.151],
[trigsimplification.txt, 157, 4.983], [wu-d.txt, 4, 0.258]]
(%i3) ( fpprintprec : 2, float ( 1424/1000 ) );
(%o3) 1.4
-----------------
Ted Woollett