How do you use 'Pi' and 'e' with GMP?

Marc Glisse marc.glisse at
Wed Mar 1 23:52:04 UTC 2017

On Wed, 1 Mar 2017, Chris Shreve wrote:

> Hello,
> I've just started using GMP (and have looked through at least half the
> archives) and
> was wondering: how do you use Pi and e in GMP.  Are pi and e defined as
> constants somewhere?  Or are there functions that return these values to an
> arbitrary precision?
> For example how would I represent/printout the first 1000 digits of
> pi^(2*e).  Moreover,
> how would I store and use it?  I assume mpf_t?

Let me save you time: do not use mpf_t from GMP, go look at MPFR (it is 
based on GMP) instead, which is more recent and much more complete. It has 
functions like mpfr_const_pi that should work for you.

Marc Glisse

More information about the gmp-discuss mailing list