ToC DocOverview CGDoc RelNotes Index PermutedIndex
Allegro CL
Home Previous Up Next Table of Contents Index
  ANSI Common Lisp   12 Numbers   12.2 Dictionary of Numbers

12.2.56 ash Function

Syntax:
ash integer count    shifted-integer

Arguments and Values:
integer - an integer.

count - an integer.

shifted-integer - an 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

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.

Notes:
 (logbitp j (ash n k))
 ==(and (>= j k) (logbitp (- j k) n))

Allegro CL Implementation Details:
None.

Home Previous Up Next Table of Contents Index
© Franz Inc. 1998-2019 - File last updated 02-07-2019