Changeset 09da99 in git for ntl/src/xdouble.c


Ignore:
Timestamp:
Nov 3, 2003, 6:33:49 PM (21 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b9f50b373314e74e83c7c060a651dd2913e1f033')
Children:
70fea801cbe08a22d1b0e9d8d1d410144e0e91f6
Parents:
be2bb37dcbd03b120f14559d378b21b104d907c4
Message:
*hannes: NTL- 5.3.1


git-svn-id: file:///usr/local/Singular/svn/trunk@6910 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ntl/src/xdouble.c

    rbe2bb3 r09da99  
    1616   if (p < 1) p = 1;
    1717
    18    if (p >= (1L << (NTL_BITS_PER_LONG-4)))
     18   if (NTL_OVERFLOW(p, 1, 0))
    1919      Error("xdouble: output precision too big");
    2020
     
    3535   }
    3636
    37    if (e >= (1L << (NTL_BITS_PER_LONG-4)))
     37   if (e >= NTL_OVFBND)
    3838      Error("xdouble: overflow");
    3939
    40    if (e <= -(1L << (NTL_BITS_PER_LONG-4)))
     40   if (e <= -NTL_OVFBND)
    4141      Error("xdouble: underflow");
    4242}
     
    391391   }
    392392
    393    if (q >= (1L << (NTL_BITS_PER_LONG-4)))
     393   if (q >= NTL_OVFBND)
    394394      Error("xdouble: overflow");
    395395
    396    if (q <= -(1L << (NTL_BITS_PER_LONG-4)))
     396   if (q <= -NTL_OVFBND)
    397397      Error("xdouble: underflow");
    398398
    399    int rr = r;
    400    double x = ldexp(1.0, rr);
     399   double x = _ntl_ldexp(1.0, r);
    401400
    402401   z.x = x;
     
    530529   double iy = floor(y+0.5);
    531530
    532    if (iy >= (1L << (NTL_BITS_PER_LONG-4)))
     531   if (iy >= NTL_OVFBND)
    533532      Error("xdouble: overflow");
    534533
    535    if (iy <= -(1L << (NTL_BITS_PER_LONG-4)))
     534   if (iy <= -NTL_OVFBND)
    536535      Error("xdouble: underflow");
    537536
     
    561560   ComputeLn10(ln10);
    562561
    563    long k = to_long( to_RR(1L << (NTL_BITS_PER_LONG-5)) * ln2 / ln10 );
     562   long k = to_long( to_RR(NTL_OVFBND/2) * ln2 / ln10 );
    564563
    565564   RR::SetPrecision(old_p);
     
    614613
    615614
    616 
    617 
    618615xdouble to_xdouble(const char *s)
    619616{
    620617   long c;
     618   long cval;
    621619   long sign;
    622620   ZZ a, b;
     
    626624
    627625   c = s[i];
    628    while (c == ' ' || c == '\n' || c == '\t') {
     626   while (IsWhiteSpace(c)) {
    629627      i++;
    630628      c = s[i];
     
    646644   b = 1;
    647645
    648    if (c >= '0' && c <= '9') {
     646   cval = CharToIntVal(c);
     647
     648   if (cval >= 0 && cval <= 9) {
    649649      got1 = 1;
    650650
    651       while (c >= '0' && c <= '9') {
     651      while (cval >= 0 && cval <= 9) {
    652652         mul(a, a, 10);
    653          add(a, a, c-'0');
     653         add(a, a, cval);
    654654         i++;
    655655         c = s[i];
     656         cval = CharToIntVal(c);
    656657      }
    657658   }
     
    662663      i++;
    663664      c = s[i];
    664 
    665       if (c >= '0' && c <= '9') {
     665      cval = CharToIntVal(c);
     666
     667      if (cval >= 0 && cval <= 9) {
    666668         got2 = 1;
    667669   
    668          while (c >= '0' && c <= '9') {
     670         while (cval >= 0 && cval <= 9) {
    669671            mul(a, a, 10);
    670             add(a, a, c-'0');
     672            add(a, a, cval);
    671673            mul(b, b, 10);
    672674            i++;
    673675            c = s[i];
     676            cval = CharToIntVal(c);
    674677         }
    675678      }
     
    702705         e_sign = 1;
    703706
    704       if (c < '0' || c > '9') Error("bad xdouble input");
     707      cval = CharToIntVal(c);
     708
     709      if (cval < 0 || cval > 9) Error("bad xdouble input");
    705710
    706711      e = 0;
    707       while (c >= '0' && c <= '9') {
     712      while (cval >= 0 && cval <= 9) {
    708713         mul(e, e, 10);
    709          add(e, e, c-'0');
     714         add(e, e, cval);
    710715         i++;
    711716         c = s[i];
     717         cval = CharToIntVal(c);
    712718      }
    713719   }
Note: See TracChangeset for help on using the changeset viewer.