memory requirements?
Sisyphus
kalinabears at iinet.net.au
Fri Jul 30 04:25:15 CEST 2004
Johan ... wrote:
> Hi
>
> I downloaded the gmp package today and compiled everything. After I compiled the
> calculator demo and tried some numbers I noticed that trying to calculate the
> 40th known mersenne prime, which is 2^20996011 - 1, caused the program to crash.
> Everything else works nice and smooth though
>
> Is this some sort of memory issue or is it something else? ...and in that case,
> how can I make it work. Btw.. I've got 512mb ram on my win xp computer.
>
> ..and the 40th mersenne prime has 6.3 * 10^6 digits.
>
The following works fine for me (Linux, with 256 megs of ram):
#include <stdio.h>
#include <gmp.h>
int main() {
mpz_t m;
mpz_init2(m, 20996012);
mpz_setbit(m, 20996011);
mpz_sub_ui(m, m, 1);
mpz_out_str(NULL, 16, m);
printf("\n");
return 0;
}
However, if I change the output base from 16 to 10, then I get a
segmentation fault when I run the executable. I assume this is a result
of the increased memory requirements needed to convert from binary to
decimal.
My guess is that you're getting a pop-up complaining about an "unknown
software exception".
Cheers,
Rob
More information about the gmp-discuss
mailing list