Hi

Sorry for the delay.

I seem to remember that 64bit builds are limited to 2^37 bits (16GB) , I read 
it somewhere on the GMP website ,I have no idea which part of MPIR has this 
restriction.

Jason


-----------------------------------------------------------
MPIR-2.5.1 bug

#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>

int main(int argc, char *argv[])
{
 // Demonstrates a MPIR bug probably with mpz_mul
 //
 // Need a computer with at least 60G of memory
 //
 // % foo
 // 3^(2^36) mod 3 equals 0
 // 3^(2^37) mod 3 does NOT equal 0 - Error

 unsigned long p;
 unsigned long e=68719476736;  // 2^36
 mpz_t pp, b;

 p = 3;  // bug does not happen with p = 2
 mpz_init(pp);
 mpz_init(b);
 // p^(2^36)
 mpz_ui_pow_ui(pp,p,e);
 // p^(2^36) mod p
 mpz_mod_ui(b,pp,p);
 printf("%d^(2^36) mod %d ", p, p);
 if (mpz_cmp_ui(b,0) == 0) {
   printf("equals 0\n");
 } else {
   printf("does NOT equal 0 - Error\n");
   exit(0);
 }
 fflush(stdout);
 // square - (p^(2^36))^2 = p^(2^37)
 mpz_mul(pp,pp,pp);
 // p^(2^37) mod p
 mpz_mod_ui(b,pp,p);
 printf("%d^(2^37) mod %d ", p, p);
 if (mpz_cmp_ui(b,0) == 0) {
   printf("equals 0\n");
 } else {
   printf("does NOT equal 0 - Error\n");
   exit(0);
 }
 fflush(stdout);
}

--
Kate Minola

-- 
You received this message because you are subscribed to the Google Groups 
"mpir-devel" group.
To post to this group, send email to mpir-devel@googlegroups.com.
To unsubscribe from this group, send email to 
mpir-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/mpir-devel?hl=en.

Reply via email to