mpn_perfect_square_p requires normalised input?

Torbjorn Granlund tg at
Sun Oct 10 20:50:14 CEST 2010

David Harvey <dmharvey at> writes:

  In GMP 5.0.1, it appears that mpn_perfect_square_p requires the input
  to be normalised, i.e. the high limb is not allowed to be zero, but
  this is not documented. If called with a zero high limb, and the
  residue tests fail to rule out the input being a non-square, then
  control is passed immediately to mpn_sqrtrem, which requires
  normalised input (typical result is a segfault).
This needs to be clarified.  Thanks for pointing this out!


More information about the gmp-bugs mailing list