Is there a pow-function for mpz_t and double

Martin Schmidt mschmidt at ifam.uni-hannover.de
Tue Apr 6 09:29:35 CEST 2010


>> I have a large integer (mpz_t or mpz_class) x and a floating point (C++
>> double) value y and want to compute x to the power of y (x^y).
> 
> You probably want to look at mpfr. What kind of result are you
> expecting? An integer ? Is your double really an integer (or maybe 1/2) ?

I expect an floating point value as the result. Maybe, an example makes
it more clear: Given a large integer x = 4294967296 and a floating point
value y = 1.53169, i want to compute x to the power of y, ie.

4294967296^1.53169

Mathematically speaking the situation is that of a mapping

f: Z x R -> R, (x,y) -> x^y

with integer values Z and real numbers R. Before I am looking at the
MPFR library I really would like to know, if there is really no
possibility for doing this in the GNU MP library.

Thanks,
Martin Schmidt


More information about the gmp-discuss mailing list