Support underscores for mpz/mpq assignments from strings

Hans Åberg haberg-1 at
Tue Jun 15 12:49:27 UTC 2021

> On 14 Jun 2021, at 19:43, Marco Bodrato <bodrato at> wrote:
> We might add such a mpz_set_mem function, requiring an explicit base and ignoring any char that is not a digit for that base.
> This should allow the maximal flexibility for any caller, that can check the syntax with its own criteria, and should never need to copy: not to remove/convert separators, not to null-terminate, not at all.
> It can not detect/return "error", of course, except "base out of range".

There are more sets of digits in Unicode, and they may not be contiguous. This is the case for superscript digits, which I transform to the ASCII range before passing to GMP. Before that, the correct string is identified by a Flex generated lexer.

More information about the gmp-discuss mailing list