bitwise-if, fxif - bitwise if
(import (rnrs)) ;R6RS
(import (rnrs arithmetic bitwise)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
(bitwise-if mask a b)
(fxif mask a b)
Returns the number that is the bit-wise "if" of the two's complement
representations of its arguments, i.e. for each bit, if it is 1 in
the corresponding bit in
becomes the value of the corresponding bit in the result, and if it is
0, the corresponding bit in
becomes the corresponding bit in the value of the result.
The following are reference implementations from R6RS:
(bitwise-ior (bitwise-and mask a)
(bitwise-and (bitwise-not mask) b))
(fxior (fxand mask a)
(fxand (fxnot mask) b))
Returns a single value; an exact integer. The fixnum variant returns
(bitwise-if #xf0f0 #x1234 #xABCD) => #x1B3D
(bitwise-if #b00111100 #b11110000 #b00001111) => #b00110011
These procedures are unique to R6RS. Compatible procedures can be
found in SRFI-60 and SRFI-151.
These procedures can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
The assertions described above are errors.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
These procedures first appeared in R6RS which got the idea from
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
Markup created by unroff 1.0sc, March 04, 2023.