The 'ash' functio performs an '
(defun ash (integer count) (or (integerp integer) (error "not an integer" integer)) (or (integerp count) (error "not an integer" count)) (let* ((shift (* integer (expt 2.0 count))) (trunc (truncate shift))) ;; XLISP implementation of (FLOOR SHIFT) (if (or (plusp shift) (= shift trunc)) trunc (1- trunc))))
The 'ash' functio performs an arithmetic shift operation on the binary
representation of the 'integer' argument, which is treated as if it were
binary.
The 'ash' function performs the computation:
floor (integer * 2^count)
Logically, the 'ash' function moves all of the bits in integer to the
left, adding
The 'ash' function is defined to behave as if integer were represented in two's complement form, regardless of how integers are represented internally.
Examples:
(ash 16 1) => 32 (ash 16 0) => 16 (ash 16 -1) => 8
(defun debug:ash (integer count) (let ((shifted (ash integer count))) (format t "integer: ~a~%" (bin-string integer :all)) (format t "shifted: ~a~%" (bin-string shifted :all)) shifted))
See