Debuging test programs, reading large numbers from files and using powers

Image image28 at xtra.co.nz
Sat Nov 5 08:25:30 CET 2005


I wrote some test programs that use the function i require, and was wondering if somebody could debug the errors in the follow lines from two separate test programs.

Program 1.  Print the results of the power of two numbers

mpz_t pow1;
mpz_t pow2;
mpz_t result;

UINT mod=2;

mpz_init(pow1);
mpz_init(pow2);
mpz_init(result);

mpz_set_str(pow1,"1000",0);
mpz_set_str(pow2,"2",0);
mpz_set_str(result,"2",0);

mpz_powm( result, pow1 , pow2 , &mod);
mpz_out_str (stdout, 1000, result);

mpz_clear( result );
mpz_clear( pow1 );
mpz_clear( pow2 );

Program 2. Read and print a file as one number 1000 bytes at a time
 INPUT_FILE;
 UCHAR line[1000];

 mpz_t result;
 mpz_init(result);
 FILELOOP;
  fread(&line,1000,1,input);

  mpz_set_str(result,line,0);

  mpz_out_str(stdout, 1000, result);

 END;

mpz_clear( result );

.. Thanks to anybody who can point out the error ahead of time

- Image
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gmplib.org/list-archives/gmp-discuss/attachments/20051105/20f87268/attachment.html


More information about the gmp-discuss mailing list