any-bit-set?
(no documentation)
SRFI-151 — Bitwise operations: logic, shifts, fields, and folds on exact integers
SRFI-151 provides bitwise operations on exact integers: boolean logic, shifts, bit field manipulation, and bit-level folds and counts.
(import (srfi 151))
(bitwise-and 6 3) ;; => 2
(bitwise-ior 4 1) ;; => 5
(bitwise-xor 5 3) ;; => 6
(arithmetic-shift 1 4) ;; => 16 (shift left by 4)
(arithmetic-shift 16 -2) ;; => 4 (shift right)
(bit-count 7) ;; => 3
It also includes bitwise-not, bit-field operations (bit-field, bit-field-set), and tests like bit-set?.
39 bindings
Syntax: (arithmetic-shift i count) Library: (srfi 151) Description: Returns i shifted left by count bits if count is positive, or right by -count bits if count is negative. Right shifts are arithmetic (sign-preserving). Example: (arithmetic-shift 8 2) => 32 (arithmetic-shift 32 -2) => 8 (arithmetic-shift -1 -1) => -1
Syntax: (bit-count i) Library: (srfi 151) Description: Returns the population count of i: the number of 1-bits for non-negative i, or the number of 0-bits for negative i. Example: (bit-count 10) => 2 (bit-count -11) => 2 (bit-count 0) => 0
Syntax: (bitwise-and i ...) Library: (srfi 151) Description: Returns the bitwise AND of its arguments. With no arguments, returns -1 (all bits set). Example: (bitwise-and 14 10) => 10 (bitwise-and 14 10 12) => 8 (bitwise-and) => -1
Syntax: (bitwise-ior i ...) Library: (srfi 151) Description: Returns the bitwise inclusive OR of its arguments. With no arguments, returns 0. Example: (bitwise-ior 10 12) => 14 (bitwise-ior) => 0
Syntax: (bitwise-not i) Library: (srfi 151) Description: Returns the bitwise complement of i. Example: (bitwise-not 10) => -11 (bitwise-not -1) => 0 (bitwise-not 0) => -1
Syntax: (bitwise-xor i ...) Library: (srfi 151) Description: Returns the bitwise exclusive OR of its arguments. With no arguments, returns 0. Example: (bitwise-xor 10 12) => 6 (bitwise-xor) => 0
Syntax: (integer-length i) Library: (srfi 151) Description: Returns the number of bits needed to represent i, not counting the sign bit. For non-negative i, this is the index of the highest set bit plus one. For negative i, it is the number of bits in (bitwise-not i). Example: (integer-length 0) => 0 (integer-length 1) => 1 (integer-length 7) => 3 (integer-length -1) => 0 (integer-length -8) => 3