-1

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

Mihai Todor
  • 8,014
  • 9
  • 49
  • 86
david
  • 11
  • 1

1 Answers1

4

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.

Mohit Jain
  • 30,259
  • 8
  • 73
  • 100
  • And there is `gmp_sprintf`, according to section 10.2 of http://mpir.org/mpir-1.3.1.pdf – osgx May 04 '14 at 01:51