Reputation: 21
i have recently installed mpir and have the following code (c++) visual studio.
char buffer[100]
mpz_t x;
mpz_set_str(x, "7612058254738945", 10);
I would like to print x into the buffer. used to use sprint but there does not seem to be any sprint for mpir
thanks
david
Upvotes: -1
Views: 174
Reputation: 30489
You can use mpz_get_str along with sprintf(%s specifier) or strcat or someother string utility.
From the same page for length of this number
To find out the right amount of space to provide for str, use mpz_sizeinbase (op, base) + 2. The two extra bytes are for a possible minus sign, and for the terminating null character.
Upvotes: 4