8.18
Bits
1 Overview
This library provides utilities for treating Racket byte string as a bit matrix with a width of 8, allowing for direct, two-dimensional access or modification of individual bits.
2 Bit Type
type
Returns #t if v is 0 or 1, #f otherwise.
Example:
> (:print-type bit?) (-> Any Boolean : Bit)
Returns #t if v is 1, #f otherwise.
Example:
> (:print-type one?) (-> Any Boolean : One)
3 Bit Matrix Operations
Gets the bit at row i and column j from bs.
Examples:
> (define bs #"U") > (bits-ref bs 0 0) - : Integer [more precisely: Bit]
1
> (bits-ref bs 0 1) - : Integer [more precisely: Bit]
0
Sets the bit at row i and column j in bs to bit.
Examples:
4 Type Conversions
procedure
(bit->boolean bit) → Boolean
bit : Bit
Convert a bit to a boolean.
procedure
(boolean->bit bool) → Bit
bool : Boolean
Convert a boolean to a bit.