gmp_printf bug?
Vincent Lefevre
vincent at vinc17.net
Wed Aug 10 14:30:36 CEST 2011
On 2011-08-10 12:18:53 +0200, Niels Möller wrote:
> Vincent Lefevre <vincent at vinc17.net> writes:
> > I've attached a small program I've written that shows how this can
> > be done. It uses double-precision arithmetic, but of course, the
> > same algorithm works in fixed point (so that mpz can be used). With
> > the included parameters, it can compute log2(x) with x between 1 and
> > 2^64 at least.
>
> Hmm, it starts by computing a table using log1p, with the value
> log_2(1+2^k) for various positive and negative integer k. Do I
> understand that correctly?
Yes, the table would be hardcoded in the source (just like other
fixed tables). AFAIK, the only drawbacks are:
* The precision cannot be extended dynamically (unless you have
some other function to compute the logarithm).
* The range of the input is limited to some interval (though you
can also do basic range reduction if needed).
Is this important in the case of gmp_printf?
> Then, the method seems suitable for computing log_2 at run time, but not
> so suitable in the bootstrap context where we want to tabulate certain
> logarithms, without relying on other tables, (or on floating point
> operations).
I'm not sure what you mean here. But perhaps I've answered a part of
this above.
--
Vincent Lefèvre <vincent at vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)
More information about the gmp-devel
mailing list