Square root of bignum using GMP
问题 I need to get the square root of a 210 digit number accurately, I thought GMP was the right tool for the job, what am I doing wrong? #include <stdlib.h> #include <stdio.h> #include "gmp.h" int main (int argc, char *argv[]) { mpz_t sq_me, sq_out, test; mpz_init(sq_me); mpz_init(sq_out); mpz_init(test); mpz_set_str (sq_me, argv[1], 10); mpz_sqrt(sq_out, sq_me); mpz_mul(test,sq_out,sq_out); gmp_printf ("%Zd\n\n", sq_out); gmp_printf ("%Zd\n\n", test); return 0; } Input: