Skip to content

Instantly share code, notes, and snippets.

@yansyaf
Created December 28, 2013 04:03
Show Gist options
  • Save yansyaf/8156010 to your computer and use it in GitHub Desktop.
Save yansyaf/8156010 to your computer and use it in GitHub Desktop.
GMP example
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
int main(void)
{
mpz_t x;
mpz_t y;
mpz_t result;
mpz_init(x);
mpz_init(y);
mpz_init(result);
mpz_set_str(x, "7612058254738945", 10);
mpz_set_str(y, "9263591128439081", 10);
mpz_mul(result, x, y);
gmp_printf("\n %Zd\n*\n %Zd\n--------------------\n%Zd\n\n", x, y, result);
/* free used memory */
mpz_clear(x);
mpz_clear(y);
mpz_clear(result);
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment