Scheme 48 Manual | Contents | In Chapter: Libraries
Previous: ASCII character encoding | Next: Byte vectors

## Bitwise integer operations

These functions use the two's-complement representation for integers. There is no limit to the number of bits in an integer. They are in the structures `bitwise` and `big-scheme`.

- `(bitwise-and integer integer) -> integer`
- `(bitwise-ior integer integer) -> integer`
- `(bitwise-xor integer integer) -> integer`
- `(bitwise-not integer) -> integer`

These perform various logical operations on integers on a bit-by-bit basis. ``ior`' is inclusive OR and ``xor`' is exclusive OR.

- `(arithmetic-shift integer bit-count) -> integer`

Shifts the integer by the given bit count, which must be an integer, shifting left for positive counts and right for negative ones. Shifting preserves the integer's sign.

- `(bit-count integer) -> integer`

Counts the number of bits set in the integer. If the argument is negative a bitwise NOT operation is performed before counting.

Previous: ASCII character encoding | Next: Byte vectors