Bitwise operations: Difference between revisions

Content added Content deleted
Line 682: Line 682:


(defun shr (x width bits)
(defun shr (x width bits)
"Compute bitwise rigth shift of x by 'bits' bits, represented on 'width' bits"
"Compute bitwise right shift of x by 'bits' bits, represented on 'width' bits"
(logand (ash x (- bits))
(logand (ash x (- bits))
(1- (ash 1 width))))
(1- (ash 1 width))))
Line 698: Line 698:


(defun rotr (x width bits)
(defun rotr (x width bits)
"Compute bitwise rigth rotation of x by 'bits' bits, represented on 'width' bits"
"Compute bitwise right rotation of x by 'bits' bits, represented on 'width' bits"
(logior (logand (ash x (- (mod bits width)))
(logior (logand (ash x (- (mod bits width)))
(1- (ash 1 width)))
(1- (ash 1 width)))