X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fbignum.lisp;h=c07fc192847b4b01754a2b4d357869d7312b59d4;hb=731da68c7e3b7f2c4bc310aa75fc75f5aead24d2;hp=ad30b2fcd76090c48b84cfbe3f3221739b9fec4a;hpb=b8fdebe9715aad2300f21f33eac147d9ca3951ed;p=sbcl.git diff --git a/src/code/bignum.lisp b/src/code/bignum.lisp index ad30b2f..c07fc19 100644 --- a/src/code/bignum.lisp +++ b/src/code/bignum.lisp @@ -377,13 +377,13 @@ ;;; results, such as GCD, use this. It assumes Result is big enough for the ;;; result. (defun subtract-bignum-buffers-with-len (a len-a b len-b result len-res) - (declare (type bignum-type a b) - (type bignum-index len-a len-b)) + (declare (type bignum-type a b result) + (type bignum-index len-a len-b len-res)) (subtract-bignum-loop a len-a b len-b result len-res %normalize-bignum-buffer)) (defun subtract-bignum-buffers (a len-a b len-b result) - (declare (type bignum-type a b) + (declare (type bignum-type a b result) (type bignum-index len-a len-b)) (subtract-bignum-loop a len-a b len-b result (max len-a len-b) %normalize-bignum-buffer)) @@ -1320,16 +1320,18 @@ (defun bignum-logcount (bignum) (declare (type bignum-type bignum)) - (let* ((length (%bignum-length bignum)) - (plusp (%bignum-0-or-plusp bignum length)) - (result 0)) + (let ((length (%bignum-length bignum)) + (result 0)) (declare (type bignum-index length) (fixnum result)) (do ((index 0 (1+ index))) - ((= index length) result) + ((= index length) + (if (%bignum-0-or-plusp bignum length) + result + (- (* length digit-size) result))) (let ((digit (%bignum-ref bignum index))) (declare (type bignum-element-type digit)) - (incf result (logcount (if plusp digit (%lognot digit)))))))) + (incf result (logcount digit)))))) ;;;; logical operations