[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: logbitp vs. logand+ash
Thank you very much for the bug report on logbitp.
Indeed there was an error in the bignum logbitp, [introduced
when the bignum types changed around akcl 530]. The error would
have occurred when the second arg was a bignum, and the index in words
was greater than the length of the bignum in words, but not more than
2 greater.
Please add the lisp patch
(defun logbitp (p i) (/= (logand i (ash 1 p)) 0))
or in num_log.c replace the definition of big_bitp by
int
big_bitp(x, p)
object x;
int p;
{ GEN u = MP(x);
int ans ;
int i = p /32;
if (signe(u) < 0)
{ save_avma;
u = complementi(u);
restore_avma;
}
if (i < lgef(u) -MP_CODE_WORDS)
{ ans = ((MP_ITH_WORD(u,i,lgef(u))) & (1 << p%32));}
else if (big_sign(x) < 0) ans = 1;
else ans = 0;
return ans;
}