diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2015-09-01 21:56:08 +0200 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2015-09-01 21:56:08 +0200 |
commit | 3b9d4b08002472731f7a4d470bda31b0fe3d98af (patch) | |
tree | c3ef9ac5bd6f72a474855a92d8d76da284a94886 /mpq | |
parent | acde9edd34bcb6a52db6fd7c21357fa2c163139e (diff) | |
download | gmp-3b9d4b08002472731f7a4d470bda31b0fe3d98af.tar.gz |
mpq/cmp.c (mpq_cmp_numden): Cast to avoid over/underflow.
Diffstat (limited to 'mpq')
-rw-r--r-- | mpq/cmp.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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; |