Bill Allombert on Thu, 25 Oct 2012 23:26:24 +0200


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

%Ps of t_REAL


Hello PARI developers,

? \p10000
   realprecision = 10018 significant digits (10000 digits displayed)
? a=Pi;
? \p38
   realprecision = 38 significant digits
? printf("%s",a)
3.1415926535897932384626433832795028842

I know this is the documented behaviour but I cannot say I ever liked it.
I would much prefer to get 10018 digits. (If I wanted 38 digits, I would
do the computation to 38 digits, or I would write %.38s).

I know I can do
printf("%.*g",precision(a),a)
but it is hardly convenient and does not work if a is a polynomial:
? printf("%.*g",precision(a),a*x)
  ***   at top-level: printf("%.*g",precis
  ***                 ^--------------------
  *** printf: incorrect type in gtofp (t_POL).
? printf("%.*s",precision(a),a*x)
3.1415926535897932384626433832795028842*x

It is worse in library mode where you do not have any control over
realprecision. It is especially painful with err_printf which is 
used for debugging, when the interesting digits are discarded.

Cheers,
Bill.