Re: libpari precision handling changes

Bill Allombert <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <ZW2eDdeQmQMO9Trt@seventeen>
On Mon, Dec 04, 2023 at 12:10:41AM +0000, James Rickards wrote:
> Dear Bill,
> 
> In one of my programs I set a tolerance to be half of the precision (i.e. precision=2^-n, tolerance=2^(-n/2)) with:
> static GEN
> deftol(long prec)
> {
>   return real2n((BITS_IN_LONG >> 1)*(2 - prec), prec);
> }
> 
> You say that this change should not break most C programs, but I am correct in saying that this function is broken now?

Yes sorry. You can do that instead

return real2n( -nbits2prec(prec2nbits(prec)>>1), prec);

This should work with both definition of prec.

Generally, if you need to do arithmetic operation on the precision, do
nbits2prec ( ...  prec2nbits(prec) ... )

This way this does not depend on the internal representation.

Cheers,
Bill.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.