Big digit numbers and root

David Gillies daggillies at gmail.com
Tue Dec 8 20:56:20 CET 2009


2009/12/8 Selçuk Keskin <selcukkeskin at live.com>:
> Hi,
> i'm studying big digit numbers .i must root a number i write the code like:
>
>        mpz_t n,m;
>        mpf_t nf,mf;
>
>
>  mpz_init_set_str(n,"71641520761751435455133616475667090434063332228247871795429",10);
>        mpz_init(m);
>        mpf_init(nf);
>        mpf_init(mf);
>
>        mpf_init_z(nf,n);
>        mpz_sqrt(mf,nf);
>        mpz_init_f(m,mf);
>
> it looks it's working at the beginning. But i calculated it at the
> calculator. Results are different. İs there a wrong at library or am i wrong

You're passing an mpf_t to mpz_sqrt()

Also note your number is not square (it's very close, but not
exactly). This is OK, but you should be aware of it. It's not prime
either: 200429218120815554269743635437 x
357440504101388365610785389017

The result should be 267659337146589069735395147283.00000... (the
fractional part is < 10^-28)

-- 
David Gillies
San Jose
Costa Rica


More information about the gmp-discuss mailing list