diff options
author | Torbjorn Granlund <tege@gmplib.org> | 2009-07-13 23:16:04 +0200 |
---|---|---|
committer | Torbjorn Granlund <tege@gmplib.org> | 2009-07-13 23:16:04 +0200 |
commit | d15e944bb01dc43a6decabd81d3e7a0037969ad2 (patch) | |
tree | f708d67bbe19066cf5e92bb15ea35bf258b21457 /mpf | |
parent | bc3956b4c933b381d978ff5b59c6c7c996a1e435 (diff) | |
download | gmp-d15e944bb01dc43a6decabd81d3e7a0037969ad2.tar.gz |
Simplify.
Diffstat (limited to 'mpf')
-rw-r--r-- | mpf/eq.c | 43 |
1 files changed, 24 insertions, 19 deletions
@@ -26,7 +26,7 @@ int mpf_eq (mpf_srcptr u, mpf_srcptr v, unsigned long int n_bits) { mp_srcptr up, vp, p; - mp_size_t usize, vsize, minsize, maxsize, n_limbs, i; + mp_size_t usize, vsize, minsize, maxsize, n_limbs, i, size; mp_exp_t uexp, vexp; mp_limb_t diff; int cnt; @@ -100,32 +100,37 @@ mpf_eq (mpf_srcptr u, mpf_srcptr v, unsigned long int n_bits) return 0; } - if (minsize != maxsize) + n_bits -= (maxsize - 1) * GMP_NUMB_BITS; + + size = maxsize - minsize; + if (size != 0) { if (up[0] != vp[0]) return 0; - } - /* Now either U or V has its limbs consumed. Check the the other operand - has just zeros in the corresponding, relevant part. */ + /* Now either U or V has its limbs consumed, i.e, continues with an + infinite number of implicit zero limbs. Check that the other operand + has just zeros in the corresponding, relevant part. */ - if (usize > vsize) - p = up + minsize - maxsize; - else - p = vp + minsize - maxsize; + if (usize > vsize) + p = up - size; + else + p = vp - size; - for (i = maxsize - minsize - 1; i > 0; i--) - { - if (p[i] != 0) - return 0; - } + for (i = size - 1; i > 0; i--) + { + if (p[i] != 0) + return 0; + } - n_bits -= (maxsize - 1) * GMP_NUMB_BITS; - - if (minsize != maxsize) - diff = p[0]; + diff = p[0]; + } else - diff = up[0] ^ vp[0]; + { + /* Both U or V has its limbs consumed. */ + + diff = up[0] ^ vp[0]; + } if (n_bits < GMP_NUMB_BITS) diff >>= GMP_NUMB_BITS - n_bits; |