Support underscores for mpz/mpq assignments from strings

Marc Glisse marc.glisse at
Mon Jun 14 16:53:58 UTC 2021

On Mon, 14 Jun 2021, Marco Bodrato wrote:

> Ciao,
> Il 2021-06-14 10:59 Vincent Lefevre ha scritto:
>> I wasn't suggesting to change mpz_set_str, but add another function.
>> Changing mpz_set_str to add another argument for a list of separators
>> would break the API.
> I do not like the idea of a list of separators...
> but we may add an "int (*) (int)" argument :-P
> This way the user can specify the preferred "isspace" function! :-D
> Il 2021-06-14 15:51 Vincent Lefevre ha scritto:
>> I think that the GMP manual is clear: mpz_set_str ignores whitespace
>> anywhere in the string (contrary to C's strtod, etc.).
> To be honest, the GMP manual is not completely correct.
> Whitespace is not allowed immediately after the minus "-" sign; nor, 
> when base = 0, in the middle of the base prefix: "0x", "0X", "0b", "0B" 
> can not be "0 x", ...
> Would you suggest to document the two exceptions, or to change the code 
> for a strict ignore-everywhere policy?

I vaguely remember past discussions that seemed to go in the reverse 
direction: change the code to stop ignoring spaces in the middle of a 

Marc Glisse

More information about the gmp-discuss mailing list