Ilya Zakharevich on Mon, 16 Sep 2024 19:03:33 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: A missing (?) function: exponentfp(x)


On Sat, Sep 14, 2024 at 11:34:00AM +0200, Bill Allombert wrote:
> On Sat, Sep 14, 2024 at 02:09:09AM -0700, Ilya Zakharevich wrote:
> > The function exponent(x) gives a very coarse value of log2(x).  The
> > function log(x)/log(2) gives a very fine value of log2(x) (but is
> > slow, especially if x has high precision).

> Why not do
> ? x=Pi;log(bitprecision(x,64))/log(2)
> %1 = 1.6514961294723187981

I thought I wrote down “why”:

  since it is about 3 orders of magnitude slower than exponent(). 

Moreover, are you sure you remember what precision() does?!

  precision(10^(10^5), 64)

(Got bitten by this myself, not so long ago… ;―)

Thanks,
Ilya