Hi Ted,
as long as there is no detailed documentation about the bigfloat directive ~h
for printf please have a look into the examples in
share\contrib\stringproc\rtestprintf.mac, lines 79ff.
The directive has the full syntax
~w,d,e,x,o,p at h
where
w = width
d = decimal digits behind floating point
e = minimal exponent digits
x = prefered exponent
o = overflow character
p = padding character
@ results in printing prefixed sign "+"
Some examples:
(%i1) fpprec:40$
(%i2) bf: exp(-20b0);
(%o2) 2.061153622438557827965940380155820976376b-9
(%i3) printf(true,"~h",bf)$
0.000000002061153622438557827965940380155820976376
(%i4) printf(true,"~40,20,,,,'#@h",bf);
#################+0.00000000206115362244
(%o4) false
(%i5) printf(true,"~40,20,,0h",bf);
0.00000000206115362244b+0
(%o5) false
(%i6) printf(false,"~,,,0h",bf);
(%o6) 0.000000002061153622438557827965940380155820976376b+0
(%i7) 2*parse_string(%);
(%o7) 4.122307244877115655931880760311641952752b-9
As Robert already mentioned, printf is autoloaded. To avoid curious
things like you observed when using printf in program blocks,
please load printf first:
load(stringproc); or load(printf);
HTH
Volker van Nek
Edwin Woollett schrieb:
> A fresh session with Maxima 5.17.1
> windows xp
>
> First use of this function is weird,
> second try works:
> -------------------------------------------
>
> (%i1) print_test(fp) :=
> block([fpprec,fpprintprec,val],
> fpprec : fp,
> fpprintprec : 8,
> display(fpprec),
> print(" "),
> print(" k value "),
> print(" "),
> for k thru 4 do
> ( val : bfloat(exp(k^2)),
> printf(true,"~2d ~14a ~%",k,string(val) ) ) )$
> (%i2) print_test(30);
> fpprec = 30
>
>
> k value
>
> (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2)
> (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2)
> (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2)
> (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2)
> (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2)
> (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2) (%i2)
> (%i2) 1 2.7182818b0
> 2 5.459815b1
> 3 8.1030839b3
> 4 8.8861105b6
> (%o2) done
>
> (%i3) print_test(30);
> fpprec = 30
>
>
> k value
>
> 1 2.7182818b0
> 2 5.459815b1
> 3 8.1030839b3
> 4 8.8861105b6
> (%o3) done
> ----------------------------------------------------
>
> Any ideas?
>
> Ted Woollett
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>