bitwiseif, fxif  bitwise if
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs arithmetic bitwise)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
SYNOPSIS
(bitwiseif mask a b)
(fxif mask a b)
DESCRIPTION
Returns the number that is the bitwise "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:
; bitwiseif
(bitwiseior (bitwiseand mask a)
(bitwiseand (bitwisenot 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
(bitwiseif #xf0f0 #x1234 #xABCD) => #x1B3D
(bitwiseif #b00111100 #b11110000 #b00001111) => #b00110011
COMPATIBILITY
These procedures are unique to R6RS. Compatible procedures can be
found in SRFI60 and SRFI151.
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
bitwiseand(3scm),
bitwiseior(3scm),
bitwisecopybit(3scm),
bitwisecopybitfield(3scm)
STANDARDS
R6RS
HISTORY
These procedures first appeared in R6RS which got the idea from
SRFI60.
AUTHORS
This page is part of the
schememanpages
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.