bitwise-copy-bit, fxcopy-bit - copy a bit from an integer onto another integer
(import (rnrs)) ;R6RS
(import (rnrs arithmetic bitwise)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
(bitwise-copy-bit n k bit)
(fxcopy-bit n k bit)
Returns the result of replacing the
The following are reference implementations from R6RS.
(let ((mask (bitwise-arithmetic-shift-left 1 k)))
(bitwise-arithmetic-shift-left bit k)
(let ((mask (fxarithmetic-shift-left 1 k)))
(fxarithmetic-shift-left bit k)
Returns a single value; an exact integer.
(bitwise-copy-bit 0 10 1) => 1024
(bitwise-copy-bit #x8000 0 1) => #x8001
(bitwise-copy-bit #x8001 15 0) => #x0001
These procedures are unique to R6RS. Similar procedures can be found
in SRFI-60 and SRFI-151.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
be non-negative, and
must be either 0 or 1.
The fixnum variant further requires that
is a fixnum and that
is non-negative and less than (fixnum-width)-1.
These procedures first appeared in R6RS. There was previously a
similar procedure in SRFI-60,
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
is very large then an implementation might try to allocate an
excessive amount of memory. In normal implementations it is expected
that all practical values of
Markup created by unroff 1.0sc, March 04, 2023.