summaryrefslogtreecommitdiff
path: root/mpf
diff options
context:
space:
mode:
authorTorbjorn Granlund <tege@gmplib.org>2011-08-07 21:28:02 +0200
committerTorbjorn Granlund <tege@gmplib.org>2011-08-07 21:28:02 +0200
commit174d4fd334cb6dce6a09e4ce3edb33bdd19d938a (patch)
tree996385720c9357186939de8f032050b76c39bcfe /mpf
parent385eadb78463524370526fb012f38d037cb3f7fe (diff)
downloadgmp-174d4fd334cb6dce6a09e4ce3edb33bdd19d938a.tar.gz
Use integer fields for mp_bases logarithm tables.
Diffstat (limited to 'mpf')
-rw-r--r--mpf/get_str.c11
-rw-r--r--mpf/out_str.c3
-rw-r--r--mpf/set_str.c9
3 files changed, 11 insertions, 12 deletions
diff --git a/mpf/get_str.c b/mpf/get_str.c
index cdadbacc3..d0cba5936 100644
--- a/mpf/get_str.c
+++ b/mpf/get_str.c
@@ -4,8 +4,8 @@
example, the number 3.1416 would be returned as "31416" in DIGIT_PTR and
1 in EXP.
-Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2005, 2006 Free
-Software Foundation, Inc.
+Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2005, 2006, 2011
+Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -178,8 +178,7 @@ mpf_get_str (char *dbuf, mp_exp_t *exp, int base, size_t n_digits, mpf_srcptr u)
conversion.) */
tstr = (unsigned char *) TMP_ALLOC (n_digits + 2 * GMP_LIMB_BITS + 3);
- n_limbs_needed = 2 + (mp_size_t)
- (n_digits / (GMP_NUMB_BITS * mp_bases[base].chars_per_bit_exactly));
+ LIMBS_PER_DIGIT_IN_BASE (n_limbs_needed, n_digits, base);
if (ue <= n_limbs_needed)
{
@@ -188,7 +187,7 @@ mpf_get_str (char *dbuf, mp_exp_t *exp, int base, size_t n_digits, mpf_srcptr u)
unsigned long e;
n_more_limbs_needed = n_limbs_needed - ue;
- e = (unsigned long) n_more_limbs_needed * (GMP_NUMB_BITS * mp_bases[base].chars_per_bit_exactly);
+ DIGITS_IN_BASE_PER_LIMB (e, n_more_limbs_needed, base);
if (un > n_limbs_needed)
{
@@ -225,7 +224,7 @@ mpf_get_str (char *dbuf, mp_exp_t *exp, int base, size_t n_digits, mpf_srcptr u)
mp_ptr dummyp, xp;
n_less_limbs_needed = ue - n_limbs_needed;
- e = (unsigned long) n_less_limbs_needed * (GMP_NUMB_BITS * mp_bases[base].chars_per_bit_exactly);
+ DIGITS_IN_BASE_PER_LIMB (e, n_less_limbs_needed, base);
if (un > n_limbs_needed)
{
diff --git a/mpf/out_str.c b/mpf/out_str.c
index afccdbb03..3e34a5341 100644
--- a/mpf/out_str.c
+++ b/mpf/out_str.c
@@ -2,7 +2,7 @@
the float OP to STREAM in base BASE. Return the number of characters
written, or 0 if an error occurred.
-Copyright 1996, 1997, 2001, 2002, 2005 Free Software Foundation, Inc.
+Copyright 1996, 1997, 2001, 2002, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -36,6 +36,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#include "gmp.h"
#include "gmp-impl.h"
+#include "longlong.h"
size_t
diff --git a/mpf/set_str.c b/mpf/set_str.c
index 214ecceb2..644b201d8 100644
--- a/mpf/set_str.c
+++ b/mpf/set_str.c
@@ -3,7 +3,7 @@
of STRING is used to figure out the base.
Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2005, 2007,
-2008 Free Software Foundation, Inc.
+2008, 2011 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -47,6 +47,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#include "longlong.h"
+
#define digit_value_tab __gmp_digit_value_tab
/* Compute base^exp and return the most significant prec limbs in rp[].
@@ -243,14 +244,12 @@ mpf_set_str (mpf_ptr x, const char *str, int base)
/* This breaks things like 0.000...0001. To safely ignore superfluous
digits, we need to skip over leading zeros. */
/* Just consider the relevant leading digits of the mantissa. */
- n_chars_needed = 2 + (size_t)
- (((size_t) prec * GMP_NUMB_BITS) * mp_bases[base].chars_per_bit_exactly);
+ LIMBS_PER_DIGIT_IN_BASE (n_chars_needed, prec, base);
if (str_size > n_chars_needed)
str_size = n_chars_needed;
#endif
- ma = 2 + (mp_size_t)
- (str_size / (GMP_NUMB_BITS * mp_bases[base].chars_per_bit_exactly));
+ LIMBS_PER_DIGIT_IN_BASE (ma, str_size, base);
mp = TMP_ALLOC_LIMBS (ma);
mn = mpn_set_str (mp, (unsigned char *) begs, str_size, base);