mpz_perfect_power_p

David Harvey dmharvey at cims.nyu.edu
Tue Dec 23 01:18:38 CET 2008


mpz_perfect_power_p() can return incorrect answers.

The following code snippet illustrates:

int main()
{
   mpz_t x;

   mpz_init (x);
   mpz_set_si (x, -64);
   printf ("%ld\n", mpz_perfect_power_p (x));
   mpz_clear (x);

   return 0;
}

It prints 0, even though -64 = (-4)^3 is a perfect power.

This was tested with GMP 4.2.4, on a macbook with ./configure ABI=32.

(This bug was discovered by Robert Bradshaw and John Cremona, see  
http://trac.sagemath.org/sage_trac/ticket/4612.)

david



More information about the gmp-bugs mailing list