summaryrefslogtreecommitdiff
path: root/mpf
diff options
context:
space:
mode:
authortege <tege@gmplib.org>2000-07-31 01:38:16 +0200
committertege <tege@gmplib.org>2000-07-31 01:38:16 +0200
commit7a74ec529bcedc242fd4f776f959d26365d327c0 (patch)
treedd148da07ffbb005b8e01d7f026b130bce0b082e /mpf
parent76739da319ed6b2456b9e979e95289facbc81b52 (diff)
downloadgmp-7a74ec529bcedc242fd4f776f959d26365d327c0.tar.gz
Develop three extra digits, not just one.
Diffstat (limited to 'mpf')
-rw-r--r--mpf/get_str.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/mpf/get_str.c b/mpf/get_str.c
index a2c53a35d..a9c6551ce 100644
--- a/mpf/get_str.c
+++ b/mpf/get_str.c
@@ -317,13 +317,18 @@ mpf_get_str (digit_ptr, exp, base, n_digits, u)
/* fall out to general code... */
}
+ /* Now that we have normalized the number, develop the digits, essentially by
+ multiplying it by BASE. We initially develop at least 3 extra digits,
+ since the two leading digits might become zero, and we need one extra for
+ rounding the output properly. */
+
/* Allocate temporary digit space. We can't put digits directly in the user
area, since we generate more digits than requested. (We allocate
- BITS_PER_MP_LIMB + 1 extra bytes because of the digit block nature of the
+ BITS_PER_MP_LIMB extra bytes because of the digit block nature of the
conversion.) */
- tstr = (unsigned char *) TMP_ALLOC (n_digits + BITS_PER_MP_LIMB + 1);
+ tstr = (unsigned char *) TMP_ALLOC (n_digits + BITS_PER_MP_LIMB + 3);
- for (digits_computed_so_far = 0; digits_computed_so_far <= n_digits;
+ for (digits_computed_so_far = 0; digits_computed_so_far < n_digits + 3;
digits_computed_so_far += dig_per_u)
{
mp_limb_t cy;