bitwise-bit-set?, fxbit-set? - test if a bit is set in an exact integer
(import (rnrs)) ;R6RS
(import (rnrs arithmetic bitwise)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
(bitwise-bit-set? ei k)
(fxbit-set? fx k)
bit is 1 in the two's complement
This is the result of the following computation:
(not (zero? (bitwise-and (bitwise-arithmetic-shift-left 1 k)
(if (fx>=? k (fx- (fixnum-width) 1))
(not (fxzero? (fxand fx (fxarithmetic-shift-left 1 k)))))
Returns a single boolean object.
(bitwise-bit-set? #b101 0)
(bitwise-bit-set? #b101 1)
This procedure is new in R6RS. SRFI-151 has the similar procedure
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.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
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.