Annoying mpz_set_str behaviour
Niels Möller
nisse at lysator.liu.se
Wed Feb 20 11:54:01 CET 2013
Torbjorn Granlund <tg at gmplib.org> 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).
I guess some users would expect mpz_set_str to have behaviour consistent
with strtol, but then this issue is not the only deviation.
Regards,
/Niels
--
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
More information about the gmp-devel
mailing list