Loïc Grenié on Tue, 19 Dec 2023 09:53:05 +0100


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

Re: Finding bitprecision


On Tue Dec, 19th, 2023 at 09:08, Aurel Page wrote:
This is the time to create 1. at your precision, not the time to find
the bitprecision.

? my(s=0,p=10^4); localprec(p); for(n=1,10^5,a=1.; s+=p);
time = 74 ms.
? my(s=0,p=10^6); localprec(p); for(n=1,10^5,a=1.; s+=p);
time = 2,718 ms.

    Indeed, however I think Ilya asked why there is no way to know the
  local bit precision without creating an object which require time to
  create.

     You can install(get_localbitprec,l), for a workaround:

? install(get_localprec,l)
? localbitprec(1000);get_localprec()
%2 = 18
? localbitprec(10000);get_localprec()
%3 = 159

       Best,

             Loïc

 
On 19/12/2023 07:20, Ilya Zakharevich wrote:
> Should not there be O(1) way to find the current localbitprecision()?
>
>    (22:17) gp > localprec(10000);   my(s); for(n=1,100000,  s+=bitprecision(1.));
>    time = 78 ms.
>    (22:17) gp > localprec(1000000); my(s); for(n=1,100000,  s+=bitprecision(1.));
>    time = 2,121 ms.
>
> Thanks,
> Ilya