summaryrefslogtreecommitdiff
path: root/mpz/cmp_si.c
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2013-02-14 13:03:57 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2013-02-14 13:03:57 +0100
commit85c105df532117da94f2a65e339b3fbbce5a19de (patch)
tree8c708428c99fec4cbde871b89a2a732299b788e5 /mpz/cmp_si.c
parent261bc4c6474baf374eb7001db5433ff34cbde89c (diff)
downloadgmp-85c105df532117da94f2a65e339b3fbbce5a19de.tar.gz
mpz/cmp_si.c: Reorganise branches.
Diffstat (limited to 'mpz/cmp_si.c')
-rw-r--r--mpz/cmp_si.c43
1 files changed, 18 insertions, 25 deletions
diff --git a/mpz/cmp_si.c b/mpz/cmp_si.c
index 9feac962d..fd847ee11 100644
--- a/mpz/cmp_si.c
+++ b/mpz/cmp_si.c
@@ -25,11 +25,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
int
_mpz_cmp_si (mpz_srcptr u, signed long int v_digit) __GMP_NOTHROW
{
- mp_size_t usize = SIZ (u);
- mp_size_t vsize;
- mp_limb_t u_digit;
- unsigned long int absv_digit;
-
#if GMP_NAIL_BITS != 0
/* FIXME. This isn't very pretty. */
mpz_t tmp;
@@ -38,30 +33,28 @@ _mpz_cmp_si (mpz_srcptr u, signed long int v_digit) __GMP_NOTHROW
ALLOC(tmp) = 2;
mpz_set_si (tmp, v_digit);
return mpz_cmp (u, tmp);
-#endif
+#else
- vsize = 0;
- if (v_digit > 0)
- vsize = 1;
- else if (v_digit < 0)
- {
- vsize = -1;
- }
- absv_digit = ABS_CAST (unsigned long int, v_digit);
+ mp_size_t vsize, usize;
- if (usize != vsize)
- return usize - vsize;
+ usize = SIZ (u);
+ vsize = (v_digit > 0) - (v_digit < 0);
- if (usize == 0)
- return 0;
+ if ((usize == 0) | (usize != vsize))
+ return usize - vsize;
+ else {
+ mp_limb_t u_digit, absv_digit;
- u_digit = PTR (u)[0];
+ u_digit = PTR (u)[0];
+ absv_digit = ABS_CAST (unsigned long, v_digit);
- if (u_digit == (mp_limb_t) absv_digit)
- return 0;
+ if (u_digit == absv_digit)
+ return 0;
- if (u_digit > (mp_limb_t) absv_digit)
- return usize;
- else
- return -usize;
+ if (u_digit > absv_digit)
+ return usize;
+ else
+ return -usize;
+ }
+#endif
}