X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fbignum.lisp;h=c07fc192847b4b01754a2b4d357869d7312b59d4;hb=68ea71d0f020f2726e3c56c1ec491d0af734b3a4;hp=2e764114ebf9100454b46dad648ccf4e4b133a83;hpb=4898ef32c639b1c7f4ee13a5ba566ce6debd03e6;p=sbcl.git diff --git a/src/code/bignum.lisp b/src/code/bignum.lisp index 2e76411..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)) @@ -960,7 +960,7 @@ (defun bignum-abs-buffer (bignum len) (unless (%bignum-0-or-plusp bignum len) - (negate-bignum-in-place bignum len))) + (negate-bignum-buffer-in-place bignum len))) ;;;; shifting @@ -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