fix problem with bignum-bit? -- return value would be truncated if sizeof(int) != sizeof(bignum_digit_type)

db4
Slava Pestov 2009-02-22 19:45:05 -06:00
parent 127f9b3578
commit 4257cd55e0
1 changed files with 4 additions and 5 deletions

View File

@ -1827,14 +1827,13 @@ int
bignum_unsigned_logbitp(int shift, bignum_type bignum) bignum_unsigned_logbitp(int shift, bignum_type bignum)
{ {
bignum_length_type len = (BIGNUM_LENGTH (bignum)); bignum_length_type len = (BIGNUM_LENGTH (bignum));
bignum_digit_type digit;
int index = shift / BIGNUM_DIGIT_LENGTH; int index = shift / BIGNUM_DIGIT_LENGTH;
int p;
if (index >= len) if (index >= len)
return 0; return 0;
digit = (BIGNUM_REF (bignum, index)); bignum_digit_type digit = (BIGNUM_REF (bignum, index));
p = shift % BIGNUM_DIGIT_LENGTH; int p = shift % BIGNUM_DIGIT_LENGTH;
return digit & (1 << p); bignum_digit_type mask = ((F_FIXNUM)1) << p;
return (digit & mask) ? 1 : 0;
} }
/* Allocates memory */ /* Allocates memory */