summaryrefslogtreecommitdiff
path: root/mpq/get_d.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-08-13 00:08:35 +0200
committerKevin Ryde <user42@zip.com.au>2003-08-13 00:08:35 +0200
commitb9cab7a0281a4ae3d38578548178a24d94d68919 (patch)
tree9ae28bf55b79ae093d25511dc03d8c8f54bf91df /mpq/get_d.c
parentc960559c40fc3a1672ff3f0422f1cfb18520a999 (diff)
downloadgmp-b9cab7a0281a4ae3d38578548178a24d94d68919.tar.gz
* mpq/get_d.c: Use mpn_get_d.
Diffstat (limited to 'mpq/get_d.c')
-rw-r--r--mpq/get_d.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/mpq/get_d.c b/mpq/get_d.c
index ea33163f2..6bd7d3767 100644
--- a/mpq/get_d.c
+++ b/mpq/get_d.c
@@ -65,6 +65,7 @@ MA 02111-1307, USA. */
double
mpq_get_d (const MP_RAT *src)
{
+ double res;
mp_ptr np, dp;
mp_ptr rp;
mp_size_t nsize = src->_mp_num._mp_size;
@@ -146,30 +147,9 @@ mpq_get_d (const MP_RAT *src)
qsize++;
}
- {
- double res;
- mp_size_t i;
- mp_size_t scale = nsize - dsize - N_QLIMBS;
-
-#if defined (__vax__)
- /* Ignore excess quotient limbs. This is necessary on a vax
- with its small double exponent, since we'd otherwise get
- exponent overflow while forming RES. */
- if (qsize > N_QLIMBS)
- {
- qp += qsize - N_QLIMBS;
- scale += qsize - N_QLIMBS;
- qsize = N_QLIMBS;
- }
-#endif
-
- res = limb2dbl (qp[qsize - 1]);
- for (i = qsize - 2; i >= 0; i--)
- res = res * MP_BASE_AS_DOUBLE + limb2dbl (qp[i]);
-
- res = __gmp_scale2 (res, GMP_NUMB_BITS * scale);
-
- TMP_FREE (marker);
- return sign_quotient >= 0 ? res : -res;
- }
+ MPN_NORMALIZE (qp, qsize);
+ res = mpn_get_d (qp, qsize, sign_quotient,
+ (long) (nsize - dsize - N_QLIMBS) * GMP_NUMB_BITS);
+ TMP_FREE (marker);
+ return res;
}