mpz_pow question
Digital Parasite
digital.parasite at gmail.com
Thu Oct 16 19:04:40 CEST 2008
On Thu, Oct 16, 2008 at 7:53 AM, Décio Luiz Gazzoni Filho
<decio at decpp.net> wrote:
> Have you stopped to think about what you're asking for? You want exponents
> larger than, at a minimum, 2^32 - 1? (Make that 2^64 - 1 in a 64-bit
> system.) Do you realize this is, at best, if your base is 2 and your
> exponent just barely overflows the range of a 32-bit integers, a 4 billion
> bit integer, which takes at least 512 megabytes of RAM to store?
You are right, when I actually think about 2^32-1 or 2^64-1 I would
not need exponents that large.
> GMP could add these functions, for the case of people who really know what
> they're doing, as convenience functions which save the programmer the chore
> of an extra mpz_get_ui() call, which would probably be done internally at
> the function anyway. But this would just invite trouble from the noob
> brigade flooding lists with question about why their code fails when trying
> to allocate more memory than there are elementary particles in the universe.
I guess it was more from a convenience point of view since I was using
mpz_t variables. I think I could just re-write my code to just store
the exponent value as an unsigned long and would be fine so I wouldn't
need an extra mpz_get_ui() call. The result of course would still
need to be stored in mpz but not every variable.
Thanks,
DP
More information about the gmp-discuss
mailing list