bitwisefirstbitset, fxfirstbitset  first bit set in an integer
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs arithmetic bitwise)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
SYNOPSIS
(bitwisefirstbitset ei)
(fxfirstbitset fx)
DESCRIPTION
Returns the index of the least significant 1 bit in the two's
complement representation of the argument. If it is 0, then −1 is
returned.
The argument to
fxfirstbitset
must be in the implementation's fixnum range.
RETURN VALUES
Returns a single value; an exact integer.
EXAMPLES
(bitwisefirstbitset 0) => 1
(bitwisefirstbitset 1) => 0
(bitwisefirstbitset 4) => 2
APPLICATION USAGE
These procedures have a variety of uses, e.g. for using integers to
represent sets, and some bithacks.
RATIONALE
Some CPUs have an instruction that is similar to this procedure, such
as the BSF instruction in the x86 ISA. If it was instead
defined by user code then it would be much slower.
COMPATIBILITY
The fixnum variant of this procedure works with the
implementationdefined fixnum range.
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.
SEE ALSO
bitwiselength(3scm)
STANDARDS
R4RS,
IEEE Scheme,
R5RS,
R6RS,
R7RS,
SRFI60, SRFI143, SRFI151
HISTORY
These procedures are new in 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/
.
Markup created by unroff 1.0sc, March 04, 2023.