I was using GMP library for build an binary arithmetic, but for multiplication, I want to return a result a multiplication without carry..
How can I implementing it?
nb: the code below give a result of multiplication with carry
How can I implementing it?
nb: the code below give a result of multiplication with carry
Code:
void multi(){
int m_bit;int m_bit2;
char *op1;
char *op2;
char *final;
mpz_t hasil_acak,hasil_acak2,hasil_pangkat,hasil_exor_temp,hasil_multi,hasil_multi_temp,hasil_exor_temp0;
mpz_init(hasil_pangkat);
mpz_init(hasil_acak);
mpz_init(hasil_acak2);
mpz_init(hasil_exor_temp0);
mpz_init(hasil_exor_temp);
mpz_init(hasil_multi_temp);
mpz_init(hasil_multi);
printf("input m-bit pertama: "); scanf("%d",&m_bit);
gmp_randstate_t rand_state;
gmp_randinit_default(rand_state);
gmp_randseed_ui (rand_state, time(NULL));
mpz_rrandomb(hasil_acak, rand_state, m_bit);
//mpz_get_ui(hasil_acak);
op1 = mpz_get_str(NULL, 2, hasil_acak);
printf("[%s]\n", op1);
printf("input m-bit kedua: "); scanf("%d",&m_bit2);
gmp_randstate_t rand_state2;
gmp_randinit_default(rand_state2);
gmp_randseed_ui (rand_state2, time(NULL));
mpz_rrandomb(hasil_acak2, rand_state2, m_bit2);
op2 = mpz_get_str(NULL, 2, hasil_acak2);
printf("[%s]\n", op2);
mpz_addmul(hasil_multi, hasil_acak, hasil_acak2);//[B]can I use other function or any code for replace this multiplication with carry? (I want a result of mutiplication without carry)[/B]
mpz_get_ui(hasil_multi);
final = mpz_get_str(NULL, 2, hasil_multi);
puts ("\n\nHasil MULTI:");
printf("[%s]\n", op1);printf("[%s]\n", op2);
puts("_*_");
printf("[%s]\n", final);
}