[BACK]Return to get_str.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpf

Diff for /OpenXM_contrib/gmp/mpf/Attic/get_str.c between version 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2000/09/09 14:13:10 version 1.1.1.3, 2000/12/01 05:45:16
Line 332  mpf_get_str (digit_ptr, exp, base, n_digits, u)
Line 332  mpf_get_str (digit_ptr, exp, base, n_digits, u)
        digits_computed_so_far += dig_per_u)         digits_computed_so_far += dig_per_u)
     {      {
       mp_limb_t cy;        mp_limb_t cy;
       /* For speed: skip trailing zeroes.  */        /* For speed: skip trailing zero limbs.  */
       if (rp[0] == 0)        if (rp[0] == 0)
         {          {
           rp++;            rp++;
           rsize--;            rsize--;
           if (rsize == 0)            if (rsize == 0)
             {              break;
               n_digits = digits_computed_so_far;  
               break;  
             }  
         }          }
   
       cy = mpn_mul_1 (rp, rp, rsize, big_base);        cy = mpn_mul_1 (rp, rp, rsize, big_base);
Line 374  mpf_get_str (digit_ptr, exp, base, n_digits, u)
Line 371  mpf_get_str (digit_ptr, exp, base, n_digits, u)
           digits_computed_so_far--;            digits_computed_so_far--;
           exp_in_base--;            exp_in_base--;
   
           if (tstr[0] == 0)            ASSERT_ALWAYS (tstr[0] != 0);
             abort ();  
         }          }
     }      }
   
   {    /* We should normally have computed too many digits.  Round the result
     size_t i;       at the point indicated by n_digits.  */
     if (digits_computed_so_far > n_digits)
     /* We should normally have computed too many digits.  Round the result      {
        at the point indicated by n_digits.  */        size_t i;
     if (digits_computed_so_far > n_digits)        /* Round the result.  */
       {        if (tstr[n_digits] * 2 >= base)
         /* Round the result.  */          {
         if (tstr[n_digits] * 2 >= base)            digits_computed_so_far = n_digits;
           {            for (i = n_digits - 1;; i--)
             digits_computed_so_far = n_digits;              {
             for (i = n_digits - 1;; i--)                unsigned int x;
               {                x = ++(tstr[i]);
                 unsigned int x;                if (x != base)
                 x = ++(tstr[i]);                  break;
                 if (x != base)                digits_computed_so_far--;
                 if (i == 0)
                   {
                     /* We had something like `bbbbbbb...bd', where 2*d >= base
                        and `b' denotes digit with significance base - 1.
                        This rounds up to `1', increasing the exponent.  */
                     tstr[0] = 1;
                     digits_computed_so_far = 1;
                     exp_in_base++;
                   break;                    break;
                 digits_computed_so_far--;                  }
                 if (i == 0)              }
                   {          }
                     /* We had something like `9999999...9d', where 2*d >= base.      }
                        This rounds up to `1', increasing the exponent.  */  
                     tstr[0] = 1;  
                     digits_computed_so_far = 1;  
                     exp_in_base++;  
                     break;  
                   }  
               }  
           }  
       }  
   
     /* We might have fewer digits than requested as a result of rounding above,    /* We might have fewer digits than requested as a result of rounding above,
        (i.e. 0.999999 => 1.0) or because we have a number that simply doesn't       (i.e. 0.999999 => 1.0) or because we have a number that simply doesn't
        need many digits in this base (i.e., 0.125 in base 10).  */       need many digits in this base (e.g., 0.125 in base 10).  */
     if (n_digits > digits_computed_so_far)    if (n_digits > digits_computed_so_far)
       n_digits = digits_computed_so_far;      n_digits = digits_computed_so_far;
   
     /* Remove trailing 0.  There can be many zeros.  */    /* Remove trailing 0.  There can be many zeros.  */
     while (n_digits != 0 && tstr[n_digits - 1] == 0)    while (n_digits != 0 && tstr[n_digits - 1] == 0)
       n_digits--;
   
     /* Translate to ASCII and copy to result string.  */
     while (n_digits != 0)
       {
         *str++ = num_to_text[*tstr++];
       n_digits--;        n_digits--;
       }
   
     /* Translate to ascii and null-terminate.  */  
     for (i = 0; i < n_digits; i++)  
       *str++ = num_to_text[tstr[i]];  
   }  
   *str = 0;    *str = 0;
   *exp = exp_in_base;    *exp = exp_in_base;
   TMP_FREE (marker);    TMP_FREE (marker);

Legend:
Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>