summaryrefslogtreecommitdiff
path: root/mpq
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2015-09-01 21:56:08 +0200
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2015-09-01 21:56:08 +0200
commit3b9d4b08002472731f7a4d470bda31b0fe3d98af (patch)
treec3ef9ac5bd6f72a474855a92d8d76da284a94886 /mpq
parentacde9edd34bcb6a52db6fd7c21357fa2c163139e (diff)
downloadgmp-3b9d4b08002472731f7a4d470bda31b0fe3d98af.tar.gz
mpq/cmp.c (mpq_cmp_numden): Cast to avoid over/underflow.
Diffstat (limited to 'mpq')
-rw-r--r--mpq/cmp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mpq/cmp.c b/mpq/cmp.c
index 7bb12302f..1758b78a6 100644
--- a/mpq/cmp.c
+++ b/mpq/cmp.c
@@ -102,11 +102,11 @@ mpq_cmp_numden (mpq_srcptr op1, mpz_srcptr num_op2, mpz_srcptr den_op2)
count_leading_zeros (cnt1, PTR(NUM(op1))[num1_size - 1]);
count_leading_zeros (cnt2, d2h);
- bits1 = tmp1_size * GMP_NUMB_BITS - cnt1 - cnt2; /* + 2 * GMP_NAIL_BITS */
+ bits1 = (mp_bitcnt_t) tmp1_size * GMP_NUMB_BITS - cnt1 - cnt2 + 2 * GMP_NAIL_BITS;
count_leading_zeros (cnt1, PTR(num_op2)[num2_size - 1]);
count_leading_zeros (cnt2, d1h);
- bits2 = tmp2_size * GMP_NUMB_BITS - cnt1 - cnt2; /* + 2 * GMP_NAIL_BITS */
+ bits2 = (mp_bitcnt_t) tmp2_size * GMP_NUMB_BITS - cnt1 - cnt2 + 2 * GMP_NAIL_BITS;
if (bits1 > bits2 + 1)
return num1_sign;