[Gmp-commit] /var/hg/gmp: Return negative value for negative input.
mercurial at gmplib.org
mercurial at gmplib.org
Tue Mar 7 15:56:13 UTC 2017
details: /var/hg/gmp/rev/f3cce34d1228
changeset: 17323:f3cce34d1228
user: Torbjorn Granlund <tg at gmplib.org>
date: Tue Mar 07 16:55:42 2017 +0100
description:
Return negative value for negative input.
diffstat:
mpf/get_d_2exp.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diffs (45 lines):
diff -r a7749cbb2d7b -r f3cce34d1228 mpf/get_d_2exp.c
--- a/mpf/get_d_2exp.c Mon Mar 06 02:52:17 2017 +0100
+++ b/mpf/get_d_2exp.c Tue Mar 07 16:55:42 2017 +0100
@@ -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 @@
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 @@
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;
}
More information about the gmp-commit
mailing list