fpprintprec and leading zeros



On 12/29/2013 5:32 PM, Robert Dodier wrote:
> On 2013-12-29, Richard Fateman <fateman at berkeley.edu> wrote:
>
>> I think a simpler fix is to change the documentation so that it
>> corresponds to the common lisp standard.
OK, here's another fix that is perhaps 2 lines of code, does something 
uniform, but perhaps not
what the original poster expects.

compute the BIGFLOAT version of each of these floats and print using 
fpprec:5 or whatever.
bfloat(0.1868)  comes out 1.868b-1
bfloat(0.1860)  comes out 1.86b-1   ;; dropping trailing zeros.

If you don't want the exponent field denoted by b, but by e,  that could 
be done by a string replacement,
I suppose.  It is certainly simpler than a page of lisp code.

I don't know for sure that fpprintprec does exactly what is documented 
for bigfloats, but if it doesn't,
that should be fixed.  I think I wrote that in 1974 or so.

Since the internal precision is really
in binary bits, not decimal digits  proper rounding/printing is a 
classical ticklish situation. I think the
way it is handled by bigfloats is by essentially having another set of 
routines to do arithmetic and
rounding in decimal. This is presumably WAY slower than necessary, but 
technically simpler.  At
least I thought so then.

RJF

> That would be convenient, but incorrect, since fpprintprec is (we hope)
> something about precision, but that doesn't correspond exactly to any
> CL format construct, which has parameters for field width and number of
> digits after the decimal point -- not the same thing in either case.
>
> I'm also opposed to nuking fpprintprec and creating some new fpprintfoo
> where foo corresponds better to CL notions.
>
> best
>
> Robert Dodier
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima