bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mpz_set_str vote


From: Alexander Kruppa
Subject: mpz_set_str vote
Date: Wed, 20 Mar 2002 23:21:54 +0100

Hi,

I read in the info page "Assinging integers" of gmp that you welcome
votes for/against a new mpz_set_str that does not ignore whitespace.

I am very much in favor of such a change.

What I would like to see most is a behaviour similar to the strtoul()
function that updates the char* to point at the first not-accepted
character. That would allow reading several white-space separated
numbers from one line easily, i.e.

char *mpz_set_str2(mpz_t ROP, char *STR, int BASE);

while (isspace(*s)) s++; /* Accept leading white space */
i=0;
while (*s != 0) {
  s = mpz_set_str(numbers[i], s, 10);
  while (isspace(*s)) s++;
  if (!isdigit(*s) && !(*s=0)) halt_catch_fire();
}

Designing parsers would be easy with the technique of finite automata if
mpz_get_str() told us how many characters exactly it accepted.

Just my 2 cents,
  Alex



reply via email to

[Prev in Thread] Current Thread [Next in Thread]