diff options
author | Kevin Ryde <user42@zip.com.au> | 2004-01-22 00:00:46 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2004-01-22 00:00:46 +0100 |
commit | 097558493d7297aa49e8f569309d5a2dd88e2c95 (patch) | |
tree | e24a0f29ffb4d410d4fa31f136fa69366a900af0 /mpf/get_d_2exp.c | |
parent | b98c8893de6d338122d8aa407297d92a15517ee2 (diff) | |
download | gmp-097558493d7297aa49e8f569309d5a2dd88e2c95.tar.gz |
* mpz/get_d_2exp.c, mpf/get_d_2exp.c: Remove x86+m68k force to double,
mpn_get_d now does this. Remove res==1.0 check for round upwards,
mpn_get_d now rounds towards zero. Move exp store to make mpn_get_d a
tail call.
Diffstat (limited to 'mpf/get_d_2exp.c')
-rw-r--r-- | mpf/get_d_2exp.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/mpf/get_d_2exp.c b/mpf/get_d_2exp.c index f944033b5..c9f67073e 100644 --- a/mpf/get_d_2exp.c +++ b/mpf/get_d_2exp.c @@ -1,6 +1,6 @@ /* double mpf_get_d_2exp (signed long int *exp, mpf_t src). -Copyright 2001, 2002, 2003 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -27,7 +27,6 @@ MA 02111-1307, USA. */ double mpf_get_d_2exp (signed long int *exp2, mpf_srcptr src) { - double res; mp_size_t size, abs_size; mp_srcptr ptr; int cnt; @@ -45,29 +44,9 @@ mpf_get_d_2exp (signed long int *exp2, mpf_srcptr src) count_leading_zeros (cnt, ptr[abs_size - 1]); cnt -= GMP_NAIL_BITS; - res = mpn_get_d (ptr, abs_size, (mp_size_t) 0, - (long) - (abs_size * GMP_NUMB_BITS - cnt)); - exp = EXP(src) * GMP_NUMB_BITS - cnt; - - /* gcc on m68k and x86 holds floats in the coprocessor, which may mean - "res" has extra precision. Force it through memory to ensure any - rounding takes place now and won't become 1.0 in the caller. */ -#if (HAVE_HOST_CPU_FAMILY_m68k || HAVE_HOST_CPU_FAMILY_x86) \ - && defined (__GNUC__) - __asm__ ("" : "=m" (res) : "0" (res)); -#endif - - /* if hardware floats are in round upwards mode then res might be 1.0 */ - if (UNLIKELY (res >= 1.0)) - { - res *= 0.5; - exp++; - } - - ASSERT (res >= 0.5); - ASSERT (res < 1.0); - *exp2 = exp; - return (size >= 0 ? res : -res); + + return mpn_get_d (ptr, abs_size, (mp_size_t) 0, + (long) - (abs_size * GMP_NUMB_BITS - cnt)); } |