Integer exponentiation without modulo?

Décio Luiz Gazzoni Filho decio at decpp.net
Sat Mar 17 16:37:40 CET 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Mar 17, 2007, at 11:13 AM, FX Coudert wrote:

> Hi all,
>
> Among the various integer exponentiation functions, I couldn't find
> one that computers a**b, where a and b are both mpz_t. mpz_powm
> performs a modulo operation, and mpz_pow_ui requires that I extract
> an unsigned long int from b, which is not possible if b is large.

If b is larger than an unsigned long int (which is at least 32 bits  
in size (I believe 64 bits in a 64-bit system), hence it can store an  
integer as large as 4294967295), that means you're computing a number  
larger than b^4294967295, which even for the smallest choice of base  
b = 2 is already 4 Gbits in size -- assuming optimal storage. Are you  
really really sure you want to perform arithmetic with numbers this  
large? Maybe you should reevaluate whatever it is that you're doing.

Décio

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFF/AtI9zcAVrR+ETURAspwAJsGqKckIAn93IDhWNaC2+k7JuWWHQCdHMlx
t+BUHKTcRuMvHihfkoDMw6E=
=/owp
-----END PGP SIGNATURE-----


More information about the gmp-discuss mailing list