[Gmp-commit] /var/hg/gmp: 3 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Sat Oct 31 16:11:15 UTC 2020
details: /var/hg/gmp/rev/a4b42199b10b
changeset: 18125:a4b42199b10b
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sat Oct 31 14:21:13 2020 +0100
description:
mpf/mul.c: Use macros.
details: /var/hg/gmp/rev/042eca061afc
changeset: 18126:042eca061afc
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sat Oct 31 14:22:31 2020 +0100
description:
mpn/generic/mod_1.c (mpn_mod_1_unnorm): Compare r<d before shifting.
details: /var/hg/gmp/rev/c24ec399b59d
changeset: 18127:c24ec399b59d
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sat Oct 31 15:15:13 2020 +0100
description:
tests/mpf/t-conv.c: Some more tests on zero.
diffstat:
mpf/mul.c | 32 ++++++++++++++++----------------
mpn/generic/mod_1.c | 14 ++++++--------
tests/mpf/t-conv.c | 25 ++++++++++++++++++++++---
3 files changed, 44 insertions(+), 27 deletions(-)
diffs (187 lines):
diff -r 69ec85f26787 -r c24ec399b59d mpf/mul.c
--- a/mpf/mul.c Thu Oct 29 18:18:37 2020 +0100
+++ b/mpf/mul.c Sat Oct 31 15:15:13 2020 +0100
@@ -1,6 +1,7 @@
/* mpf_mul -- Multiply two floats.
-Copyright 1993, 1994, 1996, 2001, 2005, 2019 Free Software Foundation, Inc.
+Copyright 1993, 1994, 1996, 2001, 2005, 2019, 2020 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library.
@@ -34,7 +35,7 @@
mpf_mul (mpf_ptr r, mpf_srcptr u, mpf_srcptr v)
{
mp_size_t sign_product;
- mp_size_t prec = r->_mp_prec;
+ mp_size_t prec = PREC (r);
mp_size_t rsize;
mp_limb_t cy_limb;
mp_ptr rp, tp;
@@ -46,12 +47,11 @@
mp_srcptr up;
mp_size_t usize;
- usize = u->_mp_size;
sign_product = 0;
- usize = ABS (usize);
+ usize = ABSIZ (u);
- up = u->_mp_d;
+ up = PTR (u);
if (usize > prec)
{
up += usize - prec;
@@ -60,8 +60,8 @@
if (usize == 0)
{
- r->_mp_size = 0;
- r->_mp_exp = 0; /* ??? */
+ SIZ (r) = 0;
+ EXP (r) = 0; /* ??? */
return;
}
else
@@ -79,15 +79,15 @@
mp_srcptr up, vp;
mp_size_t usize, vsize;
- usize = u->_mp_size;
- vsize = v->_mp_size;
+ usize = SIZ (u);
+ vsize = SIZ (v);
sign_product = usize ^ vsize;
usize = ABS (usize);
vsize = ABS (vsize);
- up = u->_mp_d;
- vp = v->_mp_d;
+ up = PTR (u);
+ vp = PTR (v);
if (usize > prec)
{
up += usize - prec;
@@ -101,8 +101,8 @@
if (usize == 0 || vsize == 0)
{
- r->_mp_size = 0;
- r->_mp_exp = 0;
+ SIZ (r) = 0;
+ EXP (r) = 0;
return;
}
else
@@ -125,10 +125,10 @@
tp += rsize - prec;
rsize = prec;
}
- rp = r->_mp_d;
+ rp = PTR (r);
MPN_COPY (rp, tp, rsize);
- r->_mp_exp = u->_mp_exp + v->_mp_exp - adj;
- r->_mp_size = sign_product >= 0 ? rsize : -rsize;
+ EXP (r) = EXP (u) + EXP (v) - adj;
+ SIZ (r) = sign_product >= 0 ? rsize : -rsize;
TMP_FREE;
}
diff -r 69ec85f26787 -r c24ec399b59d mpn/generic/mod_1.c
--- a/mpn/generic/mod_1.c Thu Oct 29 18:18:37 2020 +0100
+++ b/mpn/generic/mod_1.c Sat Oct 31 15:15:13 2020 +0100
@@ -3,8 +3,8 @@
Return the single-limb remainder.
There are no constraints on the value of the divisor.
-Copyright 1991, 1993, 1994, 1999, 2000, 2002, 2007-2009, 2012 Free Software
-Foundation, Inc.
+Copyright 1991, 1993, 1994, 1999, 2000, 2002, 2007-2009, 2012, 2020
+Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -111,21 +111,19 @@
ASSERT (un > 0);
ASSERT (d != 0);
- d <<= GMP_NAIL_BITS;
-
/* Skip a division if high < divisor. Having the test here before
normalizing will still skip as often as possible. */
- r = up[un - 1] << GMP_NAIL_BITS;
+ r = up[un - 1];
if (r < d)
{
- r >>= GMP_NAIL_BITS;
- un--;
- if (un == 0)
+ if (--un == 0)
return r;
}
else
r = 0;
+ d <<= GMP_NAIL_BITS;
+
/* If udiv_qrnnd doesn't need a normalized divisor, can use the simple
code above. */
if (! UDIV_NEEDS_NORMALIZATION
diff -r 69ec85f26787 -r c24ec399b59d tests/mpf/t-conv.c
--- a/tests/mpf/t-conv.c Thu Oct 29 18:18:37 2020 +0100
+++ b/tests/mpf/t-conv.c Sat Oct 31 15:15:13 2020 +0100
@@ -1,6 +1,6 @@
/* Test mpf_get_str and mpf_set_str.
-Copyright 1996, 2000, 2001, 2008, 2019 Free Software Foundation, Inc.
+Copyright 1996, 2000, 2001, 2008, 2019, 2020 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite.
@@ -138,7 +138,7 @@
if (mpf_cmp (x, y) != 0)
abort ();
- mpf_set_str (y, "0", 10);
+ mpf_set_str (y, " 0", 10);
mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 10);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
@@ -160,7 +160,6 @@
if (mpf_cmp (x, y) != 0)
abort ();
- mpf_set_str (y, "0", 16);
mpf_set_str (x, "00000000000000000000000000000000000000000000000000000", 16);
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
@@ -181,6 +180,26 @@
MPF_CHECK_FORMAT (x);
if (mpf_cmp (x, y) != 0)
abort ();
+ mpf_set_str (x, "+00000000000000000000000000000000000000000000000000000e-345", 9);
+ MPF_CHECK_FORMAT (x);
+ if (mpf_cmp (x, y) != 0)
+ abort ();
+ mpf_set_str (x, "-0000000000000000000000000000000000000000000000000000. at AB", 26);
+ MPF_CHECK_FORMAT (x);
+ if (mpf_cmp (x, y) != 0)
+ abort ();
+ mpf_set_str (x, "000000000000000000000000000000000000000000000000000.0 at 78", 19);
+ MPF_CHECK_FORMAT (x);
+ if (mpf_cmp (x, y) != 0)
+ abort ();
+ mpf_set_str (x, "+.0000000000000000000000000000000000000000000000000000e555", 6);
+ MPF_CHECK_FORMAT (x);
+ if (mpf_cmp (x, y) != 0)
+ abort ();
+ mpf_set_str (x, "-0.000000000000000000000000000000000000000000000000000 at -AAAAAAAAAAAAAAAAAAAAAAAA", 17);
+ MPF_CHECK_FORMAT (x);
+ if (mpf_cmp (x, y) != 0)
+ abort ();
/* Now test random values. */
More information about the gmp-commit
mailing list