When I use the cumbersome mpz_t format, my numbers will increase to an arbitrary precision, but when I use the class wrapper, they act like _int32 and wrap around to negative when > 232.
Code: Select all
int i,j; mpz_class a; mpz_t b; a=1; mpz_init(b); mpz_set_si(b,1L); i=7037; j=2123456789; a=4*i*j; mpz_mul_si(b,b,4L); mpz_mul_si(b,b,i); mpz_mul_si(b,b,j); cout << a << endl; cout << b << endl; //Test if its just a problem with cout or an actual sign issue mpz_set(b,a.get_mpz_t()); cout << b << endl;
So clearly the base C struct is working as I wish, but i'm not sure how to get the class wrapper to behave the same way. Anyone familiar with MPIR have any ideas?
Apologies for having to post here. I searched everywhere for some MPIR specific forum and could only find documentation hosting sites.