bitwise-if, fxif - bitwise if
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs arithmetic bitwise)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
SYNOPSIS
(bitwise-if mask a b)
(fxif mask a b)
DESCRIPTION
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
mask,
the corresponding bit in
a
becomes the value of the corresponding bit in the result, and if it is
0, the corresponding bit in
b
becomes the corresponding bit in the value of the result.
IMPLEMENTATION NOTES
The following are reference implementations from R6RS:
; bitwise-if
(bitwise-ior (bitwise-and mask a)
(bitwise-and (bitwise-not mask) b))
; fxif
(fxior (fxand mask a)
(fxand (fxnot mask) b))
RETURN VALUES
Returns a single value; an exact integer. The fixnum variant returns
a fixnum.
EXAMPLES
(bitwise-if #xf0f0 #x1234 #xABCD) => #x1B3D
(bitwise-if #b00111100 #b11110000 #b00001111) => #b00110011
COMPATIBILITY
These procedures are unique to R6RS. Compatible procedures can be
found in SRFI-60 and SRFI-151.
ERRORS
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.
- R7RS
-
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.
SEE ALSO
bitwise-and(3scm),
bitwise-ior(3scm),
bitwise-copy-bit(3scm),
bitwise-copy-bit-field(3scm)
STANDARDS
R6RS
HISTORY
These procedures first appeared in R6RS which got the idea from
SRFI-60.
AUTHORS
This page is part of the
scheme-manpages
project.
It includes materials from the RnRS documents.
More information can be found at
https://github.com/schemedoc/manpages/
.
Markup created by unroff 1.0sc, March 04, 2023.