Using MPFR types with GMP (mpfr with mpz)

paul zimmermann Paul.Zimmermann at inria.fr
Wed Jan 18 13:55:47 UTC 2017


> From: Flarp Emerald <flurpdadurp at gmail.com>
> Date: Wed, 18 Jan 2017 07:32:06 -0500
> 
> This is probably a really stupid question, but I need this for something
> I'm working on.
> 
> Say I have a number, 10, and I need to divide it by 2^512. 2^512 is an mpz,
> and the computation should return an MPFR type.
> 
> (until this point I've used CPP wrappers so if I get any names wrong I
> apologize in advance)
> 
> Psudeo code -> (not using GMP functions)
> 
> mpz_class big = 2^512
> mpfr_class precise = 10 / big
> 
> How would I go about doing this?

if you want to only use GMP, there is no solution for this, unless you use the MPF
layer of GMP instead of MPFR.

With MPFR, you can use mpfr_div_2ui (y, x, 512, rnd) to divide x by 2^512.

Paul Zimmermann



More information about the gmp-discuss mailing list