Support underscores for mpz/mpq assignments from strings
marc.glisse at inria.fr
Thu Jun 10 17:58:32 UTC 2021
On Thu, 10 Jun 2021, Sergey B Kirpichev wrote:
> a common feature of modern languages is using underscores as visual
> separators for digit grouping purposes in integral, floating-point and
> complex number literals, see:
> Some projects add workarounds for the gmp to allow this syntax, e.g.:
> I think, the gmp can accept this syntax. Tentative patch attached.
There is nothing special about the underscore, English uses ',', French
uses '.', some use a space, C++ seems to go for "'", etc.
C locales have thousands_sep (and grouping), similar to decimal_point,
although I don't think we support it, and it only seems allowed before the
decimal point, strangely enough.
If we add support for separators, we need to do it in a way that allows
the user the specify the separator, either through the locale or through
I don't know if mpz_inp_str is the right function to introduce this, I
would expect to see it in gmp_*scanf first, but others would know better.
More information about the gmp-discuss