Bitwise manipulation
====================

Scheme48 provides two structures for bit manipulation: bitwise integer operations, the bitwise structure, and homogeneous vectors of bytes (integers between 0 and 255, inclusive), the byte-vectors structure.

Bitwise integer operations
--------------------------

The bitwise structure exports these procedures:

 -- procedure: bitwise-and integer ... returns integer
 -- procedure: bitwise-ior integer ... returns integer
 -- procedure: bitwise-xor integer ... returns integer
 -- procedure: bitwise-not integer returns integer
     Basic twos-complement bitwise boolean logic operations.

 -- procedure: arithmetic-shift integer count returns integer
     Shifts INTEGER by the given bit count.  If COUNT is positive, the shift is a left shift; otherwise, it is a right shift. Arithmetic-shift preserves INTEGER's sign.

 -- procedure: bit-count integer returns integer
     Returns the number of bits that are set in INTEGER.  If INTEGER is negative, it is flipped by the bitwise NOT operation before counting.

          (bit-count #b11010010)                  => 4 lisp

Byte vectors
------------

The structure byte-vectors exports analogues of regular vector procedures for byte vectors, homogeneous vectors of bytes:

 -- procedure: make-byte-vector length fill returns byte-vector
 -- procedure: byte-vector byte ... returns byte-vector
 -- procedure: byte-vector? object returns boolean
 -- procedure: byte-vector-length byte-vector returns integer
 -- procedure: byte-vector-ref byte-vector index returns byte
 -- procedure: byte-vector-set! byte-vector index byte returns unspecified
     FILL and each BYTE must be bytes, ie integers within the inclusive range 0 to 255.  Note that make-byte-vector is not an exact analogue of make-vector, because the FILL parameter is required.

Old versions of Scheme48 referred to byte vectors as `code vectors' (since they were used to denote byte code).  The code-vectors structure exports make-code-vector, code-vector?, code-vector-length, code-vector-ref, and code-vector-set!, identical to the analogously named byte vector operations.