Re: Dividing 512 bit number by 128 bit number in C program

I have a huge problem finding " a mod m " using C program, when m is
128 bit number and a is 512 bit number. Can anybody suggest me a
Why don't you simply use one of the big-integer libraries? Here is an

/* gcc -O2 -lgmp a_mod_m.c -o a_mod_m */

#include <stdio.h>
#include <gmp.h>

int main(int argc, char *argv[])
mpz_t a, m, r;
int base = 10;

if (argc == 3) {
mpz_init_set_str(a, argv[1], base);
mpz_init_set_str(m, argv[2], base);

mpz_mod(r, a, m);
gmp_printf("%Zd\n", r);
else puts("usage: a_mod_m <integer 'a'> <integer 'm'>");
return 0;