Changeset a527a41 in git for libpolys/coeffs/numbers.cc


Ignore:
Timestamp:
Jul 9, 2018, 2:39:53 PM (5 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '2fa36c576e6a4ddbb1093b43c7f8e9835e17e52a')
Children:
43fa86cc32c42433e618d6c2978915bf8a580e66
Parents:
ac754db5ea554de8a6115ff7e914fb77dc57c434
Message:
move *Eati/*EatLong to numbers.cc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/numbers.cc

    rac754d ra527a41  
    598598CanonicalForm n_convSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
    599599{ STATISTIC(n_convSingNFactoryN); assume(r != NULL); assume(r->convSingNFactoryN != NULL); return r->convSingNFactoryN(n, setChar, r); }
     600
     601
     602char* nEati(char *s, int *i, int m)
     603{
     604
     605  if (((*s) >= '0') && ((*s) <= '9'))
     606  {
     607    unsigned long ii=0L;
     608    do
     609    {
     610      ii *= 10;
     611      ii += *s++ - '0';
     612      if ((m!=0) && (ii>m)) ii=ii%m;
     613    }
     614    while (((*s) >= '0') && ((*s) <= '9'));
     615    if ((m!=0) && (ii>m)) ii=ii%m;
     616    *i=(int)ii;
     617  }
     618  else (*i) = 1;
     619  return s;
     620}
     621
     622/// extracts a long integer from s, returns the rest
     623char * nEatLong(char *s, mpz_ptr i)
     624{
     625  const char * start=s;
     626
     627  while (*s >= '0' && *s <= '9') s++;
     628  if (*s=='\0')
     629  {
     630    mpz_set_str(i,start,10);
     631  }
     632  else
     633  {
     634    char c=*s;
     635    *s='\0';
     636    mpz_set_str(i,start,10);
     637    *s=c;
     638  }
     639  return s;
     640}
     641
Note: See TracChangeset for help on using the changeset viewer.