mini-gmp mpm_sqrtrem

Niels Möller nisse at lysator.liu.se
Sat Feb 22 06:46:06 UTC 2014


Hi,

I had a look at the new mpn_sqrtrem function in mini-gmp. Nice and
simple, but it's not entirely obvious that it writes exactly the right
number of limbs to the squareroot result parameter in alla cases.

The docs says that the result area is ceil(n/2) limbs. Is it possible
that the top limb can be zero? If so, the code omits writing the leading
zero. And if that's not possible, I think it would make sense with an

  assert (s->_mp_size == (n+1)/2);

and maybe a brief comment on why.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.



More information about the gmp-devel mailing list