There is a limit on the size of the exponent of an mpz itself.

A 64 bit build refers to the size of the limbs used in the
multiprecision integers, not the size of the exponents in an mpz,
which is set by GMP.

On Mon, 12 Apr 2021 at 17:47, Erich Steinböck
<erich.steinbo...@gmail.com> wrote:
>
> Even on a 64-bit system it seems that the exp argument of mpz_pow_ui cannot 
> be 2^32 or larger.
> To prove this really is a 64-bit build, first n is successfully set to 2^32.
> The second code block tries to calculate 2^(2^32) but apparently calculates 
> 2^0 instead.
>
> Is this intended or a bug?
>
> ~~~
> mpir_ui two32 = 65536ULL * 65536;
> mpz_t   n;
>
> mpz_init(n);
> mpz_init_set_ui(n, two32);
> // correctly prints: init_set_ui 4294967296 10
> printf("init_set_ui %zd %zd\r\n", two32, mpz_sizeinbase(n, 10));
>
> mpz_set_ui(n, 2);
> mpz_pow_ui(n, n, two32);
> // because 2^0 equals 1 this prints: mpz_pow_ui 4294967296 1
> printf("mpz_pow_ui %zd %zd\r\n", two32, mpz_sizeinbase(n, 10));
> ~~~
>
> --
> You received this message because you are subscribed to the Google Groups 
> "mpir-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to mpir-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/mpir-devel/CAB8Mfh0XroFTd_%3Dc5O6HDteS9KE9mCMsTnny9jSd%3DyJFZxejRA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"mpir-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mpir-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mpir-devel/CAB0xFntpo1vNJ3NGq_C3d7zYRd8s%3DdM%3DYzX87uOMbvo%2BrqGF0g%40mail.gmail.com.

Reply via email to