Support underscores for mpz/mpq assignments from strings
vincent at vinc17.net
Mon Jun 14 13:51:47 UTC 2021
On 2021-06-14 14:50:43 +0200, Hans Åberg wrote:
> > On 14 Jun 2021, at 10:59, Vincent Lefevre <vincent at vinc17.net> wrote:
> > On 2021-06-11 18:20:01 +0200, Hans Åberg wrote:
> >> But you can probably cannot change mpz_set_str,
> >> because it is modelled on C behavior.
> > It isn't. In C, whitespace isn't a separator.
> The GMP manual, sec. 5.2, is not clear on this, as it says that whitespace is discarded, whereas in C/C++ it is only the initial whitespace.
I think that the GMP manual is clear: mpz_set_str ignores whitespace
anywhere in the string (contrary to C's strtod, etc.).
/* Remove spaces from the string and convert the result from ASCII to a
byte array. */
for (i = 0; i < str_size; i++)
if (!isspace (c))
int dig = digit_value[c];
if (UNLIKELY (dig >= base))
*s++ = dig;
c = (unsigned char) *str++;
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-discuss