1:     2:     3:     4:     5:     6:     7:     8:     9:    10:    11:    12:    13:    14:    15:    16:    17:    18:    19:    20:    21:    22:    23:    24:    25:    26:    27: 
   28: 
   29:    30: 
   31: 
   32: #include "gdtoaimp.h"
   33: 
   34:  void
   35: #ifdef KR_headers
   36: ULtod(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
   37: #else
   38: ULtod(ULong *L, ULong *bits, Long exp, int k)
   39: #endif
   40: {
   41:         switch(k & STRTOG_Retmask) {
   42:           case STRTOG_NoNumber:
   43:           case STRTOG_Zero:
   44:                 L[0] = L[1] = 0;
   45:                 break;
   46: 
   47:           case STRTOG_Denormal:
   48:                 L[_1] = bits[0];
   49:                 L[_0] = bits[1];
   50:                 break;
   51: 
   52:           case STRTOG_Normal:
   53:           case STRTOG_NaNbits:
   54:                 L[_1] = bits[0];
   55:                 L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);
   56:                 break;
   57: 
   58:           case STRTOG_NoMemory:
   59:                 ;
   60:                 
   61:           case STRTOG_Infinite:
   62:                 L[_0] = 0x7ff00000;
   63:                 L[_1] = 0;
   64:                 break;
   65: 
   66:           case STRTOG_NaN:
   67:                 L[0] = d_QNAN0;
   68:                 L[1] = d_QNAN1;
   69:           }
   70:         if (k & STRTOG_Neg)
   71:                 L[_0] |= 0x80000000L;
   72:         }
   73: 
   74:  int
   75: #ifdef KR_headers
   76: strtord(s, sp, rounding, d) CONST char *s; char **sp; int rounding; double *d;
   77: #else
   78: strtord(CONST char *s, char **sp, int rounding, double *d)
   79: #endif
   80: {
   81:         static FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
   82:         FPI *fpi, fpi1;
   83:         ULong bits[2];
   84:         Long exp;
   85:         int k;
   86: 
   87:         fpi = &fpi0;
   88:         if (rounding != FPI_Round_near) {
   89:                 fpi1 = fpi0;
   90:                 fpi1.rounding = rounding;
   91:                 fpi = &fpi1;
   92:                 }
   93:         k = strtodg(s, sp, fpi, &exp, bits);
   94:         ULtod((ULong*)d, bits, exp, k);
   95:         return k;
   96:         }