Annoying mpz_set_str behaviour

Torbjorn Granlund tg at
Thu Feb 21 08:13:42 CET 2013

nisse at (Niels Möller) writes:

  Torbjorn Granlund <tg at> writes:
  > This call fails:
  >   mpz_set_str (z, "0xbade", 16)
  > Why?  Because when given an explicit base the 0x prefix is not allowed.
  > Do we really want it to work like that?
  I think so. Unless there's some other function which accepts proper hex
  digits only.
  Say I parse some file format containing hex values, and use mpz_set_str.
  Then I don't want to inherit a syntax with an optional "0x"-prefix from
  GMP, unless that's explicitly allowed in the file format specification.
  (And I probably wouldn't want to allow white space either).
You have a point.


More information about the gmp-devel mailing list