[Gmp-commit] /var/hg/gmp: 4 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Mon Jun 2 06:42:47 UTC 2014
details: /var/hg/gmp/rev/4b25c0dc9517
changeset: 16411:4b25c0dc9517
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Mon Jun 02 08:36:32 2014 +0200
description:
mpf/fits_?.h: No special case for SIZ == 0.
details: /var/hg/gmp/rev/2ec02126626f
changeset: 16412:2ec02126626f
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Mon Jun 02 08:38:02 2014 +0200
description:
mpf/int_p.c: Delay zero branch, use mpn_zero_p
details: /var/hg/gmp/rev/99f60a1c5d00
changeset: 16413:99f60a1c5d00
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Mon Jun 02 08:38:43 2014 +0200
description:
mpf/sub.c: Use SIZ, PTR, EXP and PREC macros
details: /var/hg/gmp/rev/059ac27848dd
changeset: 16414:059ac27848dd
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Mon Jun 02 08:42:21 2014 +0200
description:
ChangeLog
diffstat:
ChangeLog | 5 ++++-
mpf/fits_s.h | 7 ++-----
mpf/fits_u.h | 6 +++---
mpf/int_p.c | 19 +++++--------------
mpf/sub.c | 41 ++++++++++++++++++++++-------------------
5 files changed, 36 insertions(+), 42 deletions(-)
diffs (199 lines):
diff -r afb6dc82ad81 -r 059ac27848dd ChangeLog
--- a/ChangeLog Sun Jun 01 21:26:32 2014 +0200
+++ b/ChangeLog Mon Jun 02 08:42:21 2014 +0200
@@ -2,11 +2,14 @@
* mpf/ui_sub.c: Remove buggy code, use a wrapper to mpf_sub.
* tests/mpf/t-sub.c: More corner cases and strict checking.
- * mpf/sub.c: Use more mpn_ primitives.
+ * mpf/sub.c: Use more mpn_ primitives and macros.
* tests/mpf/t-int_p.c: Test numbers with both integer and
fractionary parts.
+ * mpf/int_p.c: Delay zero branch and use mpn_zero_p.
+ * mpf/fits_s.h: No special case for SIZ == 0.
+ * mpf/fits_u.h: Likewise.
2014-05-29 Marc Glisse <marc.glisse at inria.fr>
diff -r afb6dc82ad81 -r 059ac27848dd mpf/fits_s.h
--- a/mpf/fits_s.h Sun Jun 01 21:26:32 2014 +0200
+++ b/mpf/fits_s.h Mon Jun 02 08:42:21 2014 +0200
@@ -1,6 +1,6 @@
/* mpf_fits_s*_p -- test whether an mpf fits a C signed type.
-Copyright 2001, 2002 Free Software Foundation, Inc.
+Copyright 2001, 2002, 2014 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -42,14 +42,11 @@
mp_exp_t exp;
mp_limb_t fl;
- fs = SIZ(f);
- if (fs == 0)
- return 1; /* zero fits */
-
exp = EXP(f);
if (exp < 1)
return 1; /* -1 < f < 1 truncates to zero, so fits */
+ fs = SIZ (f);
fp = PTR(f);
fn = ABS (fs);
diff -r afb6dc82ad81 -r 059ac27848dd mpf/fits_u.h
--- a/mpf/fits_u.h Sun Jun 01 21:26:32 2014 +0200
+++ b/mpf/fits_u.h Mon Jun 02 08:42:21 2014 +0200
@@ -1,6 +1,6 @@
/* mpf_fits_u*_p -- test whether an mpf fits a C unsigned type.
-Copyright 2001, 2002, 2013 Free Software Foundation, Inc.
+Copyright 2001, 2002, 2013, 2014 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -47,8 +47,8 @@
return 1; /* -1 < f < 1 truncates to zero, so fits */
fn = SIZ(f);
- if (fn <= 0)
- return fn == 0; /* zero fits, negatives don't */
+ if (fn < 0) /* zero catched by exp == 0 */
+ return 0; /* negatives don't fit */
fp = PTR(f);
diff -r afb6dc82ad81 -r 059ac27848dd mpf/int_p.c
--- a/mpf/int_p.c Sun Jun 01 21:26:32 2014 +0200
+++ b/mpf/int_p.c Mon Jun 02 08:42:21 2014 +0200
@@ -1,7 +1,7 @@
/* mpf_integer_p -- test whether an mpf is an integer */
/*
-Copyright 2001, 2002 Free Software Foundation, Inc.
+Copyright 2001, 2002, 2014 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -36,24 +36,15 @@
int
mpf_integer_p (mpf_srcptr f) __GMP_NOTHROW
{
- mp_srcptr ptr;
mp_exp_t exp;
- mp_size_t size, frac, i;
+ mp_size_t size;
size = SIZ (f);
- if (size == 0)
- return 1; /* zero is an integer */
-
exp = EXP (f);
if (exp <= 0)
- return 0; /* has only fraction limbs */
+ return (size == 0); /* zero is an integer,
+ others have only fraction limbs */
/* any fraction limbs must be zero */
- frac = ABS (size) - exp;
- ptr = PTR (f);
- for (i = 0; i < frac; i++)
- if (ptr[i] != 0)
- return 0;
-
- return 1;
+ return mpn_zero_p (PTR (f), ABS (size) - exp);
}
diff -r afb6dc82ad81 -r 059ac27848dd mpf/sub.c
--- a/mpf/sub.c Sun Jun 01 21:26:32 2014 +0200
+++ b/mpf/sub.c Mon Jun 02 08:42:21 2014 +0200
@@ -43,8 +43,8 @@
int negate;
TMP_DECL;
- usize = u->_mp_size;
- vsize = v->_mp_size;
+ usize = SIZ (u);
+ vsize = SIZ (v);
/* Handle special cases that don't work in generic code below. */
if (usize == 0)
@@ -64,8 +64,8 @@
{
__mpf_struct v_negated;
v_negated._mp_size = -vsize;
- v_negated._mp_exp = v->_mp_exp;
- v_negated._mp_d = v->_mp_d;
+ v_negated._mp_exp = EXP (v);
+ v_negated._mp_d = PTR (v);
mpf_add (r, u, &v_negated);
return;
}
@@ -76,23 +76,23 @@
negate = usize < 0;
/* Make U be the operand with the largest exponent. */
- if (u->_mp_exp < v->_mp_exp)
+ if (EXP (u) < EXP (v))
{
mpf_srcptr t;
t = u; u = v; v = t;
negate ^= 1;
- usize = u->_mp_size;
- vsize = v->_mp_size;
+ usize = SIZ (u);
+ vsize = SIZ (v);
}
usize = ABS (usize);
vsize = ABS (vsize);
- up = u->_mp_d;
- vp = v->_mp_d;
- rp = r->_mp_d;
- prec = r->_mp_prec + 1;
- exp = u->_mp_exp;
- ediff = exp - v->_mp_exp;
+ up = PTR (u);
+ vp = PTR (v);
+ rp = PTR (r);
+ prec = PREC (r) + 1;
+ exp = EXP (u);
+ ediff = exp - EXP (v);
/* If ediff is 0 or 1, we might have a situation where the operands are
extremely close. We need to scan the operands from the most significant
@@ -351,12 +351,12 @@
/* uuuu */
/* vvvvv */
mp_size_t size;
- size = vsize + ediff - usize;
+ rsize = vsize + ediff;
+ size = rsize - usize;
ASSERT_CARRY (mpn_neg (tp, vp, size));
mpn_sub (tp + size, up, usize, vp + size, usize - ediff);
/* Should we use sub_nc then sub_1? */
MPN_DECR_U (tp + size, usize, CNST_LIMB (1));
- rsize = vsize + ediff;
}
}
}
@@ -385,9 +385,12 @@
}
done:
- r->_mp_size = negate ? -rsize : rsize;
- if (rsize == 0)
- exp = 0;
- r->_mp_exp = exp;
TMP_FREE;
+ if (rsize == 0) {
+ SIZ (r) = 0;
+ EXP (r) = 0;
+ } else {
+ SIZ (r) = negate ? -rsize : rsize;
+ EXP (r) = exp;
+ }
}
More information about the gmp-commit
mailing list