Function ASH

Syntax

• ash integer countshifted-integer

Description

ash performs the arithmetic shift operation on the binary representation of integer, which is treated as if it were binary.

ash shifts integer arithmetically left by count bit positions if count is positive, or right count bit positions if count is negative. The shifted value of the same sign as integer is returned.

Mathematically speaking, ash performs the computation `floor(integer * 2count)`.

Logically, ash moves all of the bits in integer to the left, adding zero-bits at the right, or moves them to the right, discarding bits.

ash 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

(ash -100000000000000000000000000000000 -100)

→
-79

```

None.

Exceptional Situations

Should signal an error of type type-error if integer is not an integer. Should signal an error of type type-error if count is not an integer. Might signal arithmetic-error.

None.

Notes

```
(logbitp j (ash n k))
≡ (and (>= j k)
(logbitp (- j k) n))

```