[Gmp-commit] /var/hg/gmp: 2 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Mon May 14 19:52:19 UTC 2018
details: /var/hg/gmp/rev/89e43a9eab63
changeset: 17622:89e43a9eab63
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Mon May 14 21:46:46 2018 +0200
description:
mpn/generic/get_d.c: Enhance generic code using DBL_MANT_DIG.
details: /var/hg/gmp/rev/274a52c270c0
changeset: 17623:274a52c270c0
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Mon May 14 21:47:51 2018 +0200
description:
Changelog
diffstat:
ChangeLog | 13 +++++++++++++
mpn/generic/get_d.c | 45 ++++++++++++++++++++++++++++++++++++---------
2 files changed, 49 insertions(+), 9 deletions(-)
diffs (96 lines):
diff -r f1f2b927d1c7 -r 274a52c270c0 ChangeLog
--- a/ChangeLog Sun May 13 09:47:33 2018 +0200
+++ b/ChangeLog Mon May 14 21:47:51 2018 +0200
@@ -1,3 +1,16 @@
+2018-05-14 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * mpn/generic/dcpi1_bdiv_q.c (mpn_dcpi1_bdiv_q_n): Decl. static.
+ (mpn_dcpi1_bdiv_q_n_itch): Declare static.
+ * mpn/generic/dcpi1_divappr_q.c (mpn_dcpi1_divappr_q_n): static.
+ * mpn/generic/matrix22_mul.c (mpn_matrix22_mul_strassen): static.
+ * mpn/generic/mu_div_qr.c (mpn_mu_div_qr_choose_in): static.
+ * mpn/generic/mu_divappr_q.c (mpn_preinv_mu_divappr_q): static.
+ (mpn_mu_divappr_q_choose_in): static.
+ * gmp-impl.h: Remove declaration of previous functions.
+
+ * mpn/generic/get_d.c: Enhance generic code using DBL_MANT_DIG.
+
2018-05-04 Marco Bodrato <bodrato at mail.dm.unipi.it>
* doc/gmp.texi (mpq_*_str): Document the full base allowed range.
diff -r f1f2b927d1c7 -r 274a52c270c0 mpn/generic/get_d.c
--- a/mpn/generic/get_d.c Sun May 13 09:47:33 2018 +0200
+++ b/mpn/generic/get_d.c Mon May 14 21:47:51 2018 +0200
@@ -4,7 +4,8 @@
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
FUTURE GNU MP RELEASES.
-Copyright 2003, 2004, 2007, 2009, 2010, 2012 Free Software Foundation, Inc.
+Copyright 2003, 2004, 2007, 2009, 2010, 2012, 2018 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library.
@@ -32,6 +33,12 @@
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
+#include "config.h"
+
+#if HAVE_FLOAT_H
+#include <float.h> /* for DBL_MANT_DIG and FLT_RADIX */
+#endif
+
#include "gmp-impl.h"
#include "longlong.h"
@@ -354,21 +361,41 @@
#endif
#if ! FORMAT_RECOGNIZED
- { /* Non-IEEE or strange limb size, do something generic. */
+
+#if !defined(GMP_DBL_MANT_BITS)
+#if defined(DBL_MANT_DIG) && FLT_RADIX == 2
+#define GMP_DBL_MANT_BITS DBL_MANT_DIG
+#else
+/* FIXME: Chose a smarter default value. */
+#define GMP_DBL_MANT_BITS (16 * sizeof (double))
+#endif
+#endif
+
+ { /* Non-IEEE or strange limb size, generically convert
+ GMP_DBL_MANT_BITS bits. */
+ mp_limb_t l;
+ int m;
mp_size_t i;
double d, weight;
unsigned long uexp;
/* First generate an fp number disregarding exp, instead keeping things
within the numb base factor from 1, which should prevent overflow and
- underflow even for the most exponent limited fp formats. The
- termination criteria should be refined, since we now include too many
- limbs. */
- weight = 1/MP_BASE_AS_DOUBLE;
- d = up[size - 1];
- for (i = size - 2; i >= 0; i--)
+ underflow even for the most exponent limited fp formats. */
+ i = size - 1;
+ l = up[i];
+ count_leading_zeros (m, l);
+ m = m + GMP_DBL_MANT_BITS - GMP_LIMB_BITS;
+ if (m < 0)
+ l &= GMP_NUMB_MAX << -m;
+ d = l;
+ for (weight = 1/MP_BASE_AS_DOUBLE; m > 0 && --i >= 0;)
{
- d += up[i] * weight;
+ l = up[i];
+ m -= GMP_NUMB_BITS;
+ if (m < 0)
+ l &= GMP_NUMB_MAX << -m;
+ d += l * weight;
weight /= MP_BASE_AS_DOUBLE;
if (weight == 0)
break;
More information about the gmp-commit
mailing list