Re: How to show few decimal digits of a real number?

Karim Belabas <[email protected]> Mon, 2 Sep 2024 17:43:06 +0200
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <[email protected]>
* Georgi Guninski [2024-09-02 17:40]:
> I have real number A and want to show only few fractional digits,
> how to do it directly without floor/round?
> 
> The following doesn't work:
> ? precision(Pi)
> %3 = 38
> ? precision(Pi,2)
> %4 = 3.141592653589793239

See ??printf

  ? printf("%.2f", Pi)
  3.14

Cheers,

    K.B.
-- 
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/