diff options
Diffstat (limited to 'mpf')
-rw-r--r-- | mpf/get_d_2exp.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/mpf/get_d_2exp.c b/mpf/get_d_2exp.c index 2bc2248ce..61a069e60 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-2004 Free Software Foundation, Inc. +Copyright 2001-2004, 2017 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -33,17 +33,17 @@ see https://www.gnu.org/licenses/. */ double -mpf_get_d_2exp (signed long int *exp2, mpf_srcptr src) +mpf_get_d_2exp (signed long int *expptr, mpf_srcptr src) { mp_size_t size, abs_size; mp_srcptr ptr; int cnt; - long exp; + double d; size = SIZ(src); if (UNLIKELY (size == 0)) { - *exp2 = 0; + *expptr = 0; return 0.0; } @@ -52,9 +52,8 @@ mpf_get_d_2exp (signed long int *exp2, mpf_srcptr src) count_leading_zeros (cnt, ptr[abs_size - 1]); cnt -= GMP_NAIL_BITS; - exp = EXP(src) * GMP_NUMB_BITS - cnt; - *exp2 = exp; + *expptr = EXP(src) * GMP_NUMB_BITS - cnt; - return mpn_get_d (ptr, abs_size, (mp_size_t) 0, - (long) - (abs_size * GMP_NUMB_BITS - cnt)); + d = mpn_get_d (ptr, abs_size, 0, -(abs_size * GMP_NUMB_BITS - cnt)); + return size >= 0 ? d : -d; } |