summaryrefslogtreecommitdiff
path: root/mpq/get_d.c
diff options
context:
space:
mode:
authortege <tege@gmplib.org>1996-05-26 21:44:14 +0200
committertege <tege@gmplib.org>1996-05-26 21:44:14 +0200
commit4038810e1f27935931e173138c769567ad6a8884 (patch)
treed7afb1501bb1445d0599debef8701f80651affcb /mpq/get_d.c
parent5dbb236ecf5e8f68ebb18babe037b6d48ddc7076 (diff)
downloadgmp-4038810e1f27935931e173138c769567ad6a8884.tar.gz
Use __gmp_scale2 instead of ldexp.
Get rid of limbbase and use MP_BASE_AS_DOUBLE instead. Don't include math.h.
Diffstat (limited to 'mpq/get_d.c')
-rw-r--r--mpq/get_d.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/mpq/get_d.c b/mpq/get_d.c
index 18c01a63f..cb4e800d3 100644
--- a/mpq/get_d.c
+++ b/mpq/get_d.c
@@ -23,8 +23,6 @@ MA 02111-1307, USA. */
#include "gmp-impl.h"
#include "longlong.h"
-#include <math.h>
-
/* Algorithm:
1. Develop >= n bits of src.num / src.den, where n is the number of bits
in a double. This (partial) division will use all bits from the
@@ -138,15 +136,14 @@ mpq_get_d (src)
}
{
- const double limbbase = 2.0 * ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1));
double res;
mp_size_t i;
res = qp[qsize - 1];
for (i = qsize - 2; i >= 0; i--)
- res = res * limbbase + qp[i];
+ res = res * MP_BASE_AS_DOUBLE + qp[i];
- res = ldexp (res, BITS_PER_MP_LIMB * (nsize - dsize - N_QLIMBS));
+ res = __gmp_scale2 (res, BITS_PER_MP_LIMB * (nsize - dsize - N_QLIMBS));
TMP_FREE (marker);
return sign_quotient >= 0 ? res : -res;