diff options
author | Torbjorn Granlund <tege@gmplib.org> | 2011-08-07 21:28:02 +0200 |
---|---|---|
committer | Torbjorn Granlund <tege@gmplib.org> | 2011-08-07 21:28:02 +0200 |
commit | 174d4fd334cb6dce6a09e4ce3edb33bdd19d938a (patch) | |
tree | 996385720c9357186939de8f032050b76c39bcfe /mpq/get_str.c | |
parent | 385eadb78463524370526fb012f38d037cb3f7fe (diff) | |
download | gmp-174d4fd334cb6dce6a09e4ce3edb33bdd19d938a.tar.gz |
Use integer fields for mp_bases logarithm tables.
Diffstat (limited to 'mpq/get_str.c')
-rw-r--r-- | mpq/get_str.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mpq/get_str.c b/mpq/get_str.c index 074c48c9f..d85914f94 100644 --- a/mpq/get_str.c +++ b/mpq/get_str.c @@ -1,6 +1,6 @@ /* mpq_get_str -- mpq to string conversion. -Copyright 2001, 2002, 2006 Free Software Foundation, Inc. +Copyright 2001, 2002, 2006, 2011 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -21,6 +21,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include <string.h> #include "gmp.h" #include "gmp-impl.h" +#include "longlong.h" char * mpq_get_str (char *str, int base, mpq_srcptr q) @@ -36,10 +37,9 @@ mpq_get_str (char *str, int base, mpq_srcptr q) /* This is an overestimate since we don't bother checking how much of the high limbs of num and den are used. +2 for rounding up the chars per bit of num and den. +3 for sign, slash and '\0'. */ - str_alloc = ((size_t) ((ABS (q->_mp_num._mp_size) + q->_mp_den._mp_size) - * GMP_LIMB_BITS - * mp_bases[ABS(base)].chars_per_bit_exactly)) - + 5; + DIGITS_IN_BASE_PER_LIMB (str_alloc, ABS (q->_mp_num._mp_size) + q->_mp_den._mp_size, ABS(base)); + str_alloc += 6; + str = (char *) (*__gmp_allocate_func) (str_alloc); } |