James Rickards on Mon, 04 Dec 2023 01:10:54 +0100


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

Re: libpari precision handling changes


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?

Similarly, do you have an easy way for the program to detect if this is pre or post precision change? Presumably if prec<64 then it will be an old version, but for very high precision inputs that may be ambiguous. I'd like to have code that works on at least both 2.15 and 2.16 simultaneously.

Best,
James


From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
Sent: Sunday, December 3, 2023 1:52 PM
To: pari-dev@pari.math.u-bordeaux.fr <pari-dev@pari.math.u-bordeaux.fr>
Subject: libpari precision handling changes
 
Dear PARI developers,

I committed a change to the way the precision is manipulated in the
C library.

Now the precision is a multiple of BITS_IN_LONG.
DEFAULTPREC is 64      (instead of 3)
MEDDEFAULTPREC is 128  (instead of 4)
BIGDEFAULTPREC is 192  (instead of 5)
realprec return a number of bits, cgetr takes a number of bits as input, the
prototype code 'p' of 'install' passes a number of bits so every function that
takes the argument prec, will receive a number of bits etc.

While this is a major change, this should not break most C programs that used
the libpari API correctly. For example, this does not impact GP2C-generated
code.

However this might affect programs written in other languages that they cannot
use the C headers.

This does not affect GP.

Cheers,
Bill.