Wrong result after mpz_mul_2exp

Paul Zimmermann Paul.Zimmermann at loria.fr
Thu Nov 1 11:03:14 CET 2007


Dear Sebastian,

   I've written some code and get some misteryos error. I'm shift the word=20
   0x87654321 once to the left. But then I'm geting  the result 0x0ECb8642=20
   instead of 0x0ECa8642. The following code is an minimal exsample for the=20
   problem. With all other words I try it works fine.

I guess your computer is little endian. Please try ENDIAN=0 or -1 instead of 1
(5th parameter of mpz_import and mpz_export). Hint: print the value of lmpz_A
with gmp_printf ("lmpz_A=%Zd\n", lmpz_A) before the mpz_mul_2exp instruction.

Paul Zimmermann


More information about the gmp-discuss mailing list