| Bill Allombert on Mon, 04 Dec 2023 11:15:25 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: libpari precision handling changes |
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.