Next: Generic dispatch system, Previous: Condition system, Up: System facilities
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.
The bitwise
structure exports these procedures:
Basic twos-complement bitwise boolean logic operations.
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.
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
The structure byte-vectors
exports analogues of regular vector
procedures for byte vectors, homogeneous vectors of bytes:
Fill and each byte must be bytes, i.e. integers within the inclusive range 0 to 255. Note that
make-byte-vector
is not an exact analogue ofmake-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.