Merge pull request #3932 from guidovranken/zd12012

MP integer.c: Use unsigned integers in mp_is_bit_set
This commit is contained in:
Sean Parkinson
2021-04-01 15:41:01 +10:00
committed by GitHub

View File

@ -1446,10 +1446,10 @@ int mp_set (mp_int * a, mp_digit b)
/* check if a bit is set */ /* check if a bit is set */
int mp_is_bit_set (mp_int *a, mp_digit b) int mp_is_bit_set (mp_int *a, mp_digit b)
{ {
int i = (int)(b / DIGIT_BIT); /* word index */ mp_digit i = b / DIGIT_BIT; /* word index */
int s = b % DIGIT_BIT; /* bit index */ mp_digit s = b % DIGIT_BIT; /* bit index */
if (a->used <= i) { if ((mp_digit)a->used <= i) {
/* no words avaialable at that bit count */ /* no words avaialable at that bit count */
return 0; return 0;
} }