c - Square root of bignum using GMP -


I have to get a square root of 210 point numbers correctly, I thought that GMP was the right tool for the job Am i doing wrong

  #include & lt; Stdlib.h & gt; # Include & lt; Stdio.h & gt; #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:

24524664490027821197651766357308801846702678767833275974341445171506160083003858 72169522083993320715491036268271916798640797767232430056005920356312465612184658 17904100131859299619933817012149335034875870551067

Output:

49522383313031109809242226159886283348695660460381271324714928680654813093947239 9634016783775955618921028

24524664490027821197651766357308801846702678767833275974341445171506160083003858 72169522083993320715491034366358025027526868495267716284867043049443779615862887 47102011391915422793532619329760963626718900576784

the code is needed For the floating point square root, you can see that the initial input and end We output the same.

  #include & lt; Stdlib.h & gt; # Include & lt; Stdio.h & gt; #include "gmp.h" int main (int argc, char * argv []) {mpf_t sq_me, sq_out, test; Mpf_set_default_prec (10000); Mpf_init (sq_me); Mpf_init (sq_out); Mpf_init (test); Mpf_set_str (sq_me, argv [1], 10); Mpf_sqrt (sq_out, sq_me); Mpf_mul (test, sq_out, sq_out); Gmp_printf ("Input:% FF \ n \ n", sq_me); Gmp_printf ("square root:% .200Ff \ n \ n", sq_out); Gmp_printf ("re-square:% FF \ n \ n", test); Return 0; }  

Here's production with its parameters:

  Input: 2452466449002782ll9765l76635730880l84670267876783327597434l44 5l7l506l6008300385872l695220839933207l549l03626827l9l679864079776723243005 60059203563l24656l2l84658l7904l00l3l8592996l99338l70l2l4933503487587055l06 7,000000 root: 495223833l303ll09809242226l5988628334869566046038l27l3247l492 86806548l309394723996340l67837759556l892l028,l9202568258368255653837l684l2 9235643266l5486l43320l4l06l7463895l39059667295039498l098992388ll6308833260 04535647648563996l4425092427775734424805982602420l6427485l5325655438898558 17807282091590722890002 again squared : 2452466449002782119765176635730880184670267876783327597434144 51715061600833003858721695220839933207154910362682719167986407977672324300560059203563124656121846581790410013185929961993381701214933503487587055106 7.000000 

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -