fpprintprec and leading zeros



On 2013-12-29, Tamas Papp <tkpapp at gmail.com> wrote:

> The problem with that is that it still won't give the correct result for
> 0.1860.

Well, I dunno. What should happen with trailing zeros in general? Should
0.5 be printed as 0.500000000000000 by default? Maybe, maybe not.

> I don't think that there is an easy way of tackling this problem with
> FORMAT tricks, so I wrote up some simple code this morning for float
> formatting, included below (yes, I know, maybe I care about this too
> much :P).  I believe that when called with EFFECTIVE-PRINTPREC, it would
> produce the correct formatting.
>
> If you would be willing to include it in Maxima, I am happy to do some
> extensive testing.

The code seems reasonable, although for some combination of magnitude
and precision, the output appears to be an integer -- I think the output
should always be parseable as a float. If you'd like to pursue it, my
advice is to make a table showing the output for various input and
compare the new output to the output of the existing float formatter,
and then make some argument as to how the new output is better.

It will make it a little easier if the new code is presented as a patch
which can be applied via the 'patch' program. Remember that there are
two display modes (display2d = true or false) and I think they use
different formatting routines (you can check that I guess). You will
want to present output in both modes.

best,

Robert Dodier