mpz_root aborts for n-th root when n is very large

Marc Glisse marc.glisse at
Sun Feb 27 22:19:09 CET 2011

On Sun, 27 Feb 2011, Torbjorn Granlund wrote:

> OK, computing a high root of 1 will ask for undue of memory.
> I'd claim that computing the nth root of x, x < 2^n is somewhat strange,
> since the result is always 1.
> For x >= 2^n, the memory need is suddenly O(n) which isn't unreasonable.
> Do you agree?


> Now, should we do something about this?  Should we check x < 2^n,
> i.e. log(x) < n?

It doesn't look like a very expensive check (and it doesn't even need to 
be tight). But then I have no idea how useful it would be. Maybe Volker 
could tell a bit more?

Marc Glisse

More information about the gmp-bugs mailing list