bitwisebitset?, fxbitset?  test if a bit is set in an exact integer
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs arithmetic bitwise)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
SYNOPSIS
(bitwisebitset? ei k)
(fxbitset? fx k)
DESCRIPTION
Returns
#t
if the
kth
bit is 1 in the two's complement
representation of
ei
or
fx,
respectively, and
#f
otherwise.
This is the result of the following computation:
; bitwisebitset?
(not (zero? (bitwiseand (bitwisearithmeticshiftleft 1 k)
ei)))
; fxbitset?
(if (fx>=? k (fx (fixnumwidth) 1))
(fxnegative? fx)
(not (fxzero? (fxand fx (fxarithmeticshiftleft 1 k)))))
RETURN VALUES
Returns a single boolean object.
EXAMPLES
(bitwisebitset? #b101 0)
=> #t
(bitwisebitset? #b101 1)
=> #f
COMPATIBILITY
This procedure is new in R6RS. SRFI151 has the similar procedure
bitset?.
ERRORS
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.
Raised if k is negative.
SEE ALSO
bitwisearithmeticshiftright(3scm),
bitwisefirstbitset(3scm),
bitwiselength(3scm)
STANDARDS
R6RS
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/
.
BUGS
Note that even in the fixnum variant, k is allowed to be greater
than the fixnum width. There have been bugs related to this aspect in
Sagittarius 0.4.9 and IronScheme TFS:101169.
Markup created by unroff 1.0sc, March 04, 2023.