Exactly 64 bits
MAHMOUD MAQABLEH
maqableh_cs at yahoo.com
Sun Mar 7 00:49:54 CET 2010
Hello all,
I wrote program that calculate the nth value of x after iteration the logistic map using GMP on windows vista as operating system. Also, I am doing circle left shift with 11 bits on the final value. I would like to have all the values to be 64-bit exactly. Unfortunately, I found this process is not accurate and it sometimes give numbers bigger than the 64-bit.
Could anyone help me to have always 64-bit stored in each variable bafore and afer any operation?
mpf_init2(r,64);
mpf_init2(x0,64);
mpf_init2(xn,64);
mpf_init2(A,64);
mpz_init2(x1,64);
mpz_init2(ci,64);
for (x=1; x<=35; x++)
{
// x1=r*x0*(1-x0);
mpf_mul(xn,r,x0);
mpf_ui_sub(A,1,x0);
mpf_mul(x0,xn,A);
}
gmp_printf( "\n The Value of Xn after 35 Iteration = %.Ff \n", x0);
mpf_mul_2exp(xn, x0, 64); //convert the value to Integer (64 bits) x0* 2^64
mpz_set_f(x1, xn); // Asign the value to the variable x1 as 64-bit integer
mpz_mul_2exp(x1, x1, 11); // circlue left shift with 11 bits
Thanks very much in advance.
Best wishes,
Mahmoud Maqableh
More information about the gmp-discuss
mailing list