Integers conversions

Torbjorn Granlund tg at
Tue Sep 27 11:39:07 CEST 2011

Zdenek Prikryl <iprikryl at> writes:

  the following situation is a little bit confusing. Let's assume
  following situation:
  mpz_t mp;
  mpz_init_set_ui(mp, 0xffffffffU);
  printf("s %x, u %x, s %s\n", mpz_get_ui(mp),
                               mpz_get_str(NULL, 16, mp));
  I'd expect that all print outs will be the same (i.e. 0xffffffff). But
  the real situation is different and the output is:
  s ffffffff, u 7fffffff, s ffffffff
  Why the mpz_get_si() returns wrong value? It should return -1 (0xffffffff)?

Please read the documentation for mpz_get_si.


More information about the gmp-discuss mailing list