limit on number of digits when printing?
Sisyphus
kalinabears at iinet.net.au
Fri Sep 3 20:50:11 CEST 2004
ami ... wrote:
> Hi!
>
> There seems to be an upper limit on the possible
> number of digits during output.
>
> Consider this program:
> //===========================================
> #include <stdio.h>
> #include <gmp.h>
>
> int main() {
> mpz_t m;
> mpz_init(m);
> mpz_setbit(m, 1000000);
> mpz_out_str (stdout, 10, m) ;
>
> //no problem printing this one...
>
> printf("\n\n");
>
> mpz_setbit(m,10000000);
> //works fine up to here
>
> mpz_out_str(stdout, 10, m);
> //this is where the program ends with a stack
> overflow or something.
>
> mpz_clear(m);
> return 0;
> }
> //======================================
>
> The same thing happens when I try to write to a file.
> Is there some way to get around this?
>
It's the conversion from the internal representation to a base 10
representation that's causing the problem.
The problem should not arise if you output the number in base 2, 4, 8,
16, or 32 (instead of base 10) .... assuming that's acceptable to you,
of course :-)
Cheers,
Rob
More information about the gmp-discuss
mailing list