Next: オクテットベクタ, Previous: Requiring extensions, Up: ライブラリモジュール - SRFI [Contents][Index]

`srfi-60`

- 整数に対するビット操作- Module:
**srfi-60** -
This srfi provides bit operations on integers, regarding them as 2’s complement representation. It is compatible to SLIB’s

`logical`

module.The newer srfi-151 (see ビット演算) provides the same functionality and more, with more consistent naming. We recommend new code to use srfi-151, while we keep srfi-60 for the backward compatibility.

The following procedures are Gauche built-in. See 基本的なビット演算, for the description.

lognot logand logior logxor logtest logcount integer-length logbit? copy-bit bit-field copy-bit-field ash

The following procedures are defined in srfi-151. See ビット演算, for the description.

bitwise-not bitwise-and bitwise-ior bitwise-xor arithmetic-shift bit-count bitwise-if bit-set? copy-bit first-set-bit

We describe procedures that are unique in srfi-60 below.

- Function:
**bitwise-merge***mask n0 n1* [SRFI-60] {

`srfi-60`} Same as`bitwise-if`

(see ビット演算).

- Function:
**any-bits-set?***mask n* [SRFI-60] {

`srfi-60`} Same as builtin`logtest`

(see 基本的なビット演算). It is also called`any-bit-set?`

in srfi-151 (see ビット演算).

- Function:
**log2-binary-factors***n* [SRFI-60] {

`srfi-60`} It is also called as`first-set-bit`

in this srfi, which is also in srfi-151 (see ビット演算). This is equivalent to Gauche’s built-in`twos-exponent-factor`

(see 基本的なビット演算).

- Function:
**rotate-bit-field***n count start end* [SRFI-60] {

`srfi-60`} This is equivalent to`bit-field-rotate`

in srfi-151 (see ビット演算).

- Function:
**reverse-bit-field***n start end* [SRFI-60] {

`srfi-60`} This is equivalent to`bit-field-reverse`

in srfi-151 (see ビット演算).

- Function:
**integer->list***n :optional len* [SRFI-60] {

`srfi-60`} Breaks`n`to each bits, representing`1`

as`#t`

and`0`

as`#f`

, LSB last, and returns a list of them. If a nonnegative integer`len`is given, it specifies the length of the result. If it is omitted,`(integer-length n)`

is used.(integer->list 10) ⇒ (#t #f #t #f) (integer->list 10 6) ⇒ (#f #f #t #f #t #f)

Srfi-151 has similar procedure

`bits->list`

, with a reversed bit order (LSB first) (see ビット演算).

- Function:
**list->integer***lis* [SRFI-60] {

`srfi-60`} Takes a list of boolean values, replaces the true value for`1`

and the false value for`0`

, and compose an integer regarding each value as a binary digit. If`n`is nonnegative integer,`(eqv? (list->integer (integer->list n)) n)`

is true.(list->integer '(#f #t #f #t #f)) ⇒ 10

Srfi-151 has similar procedure

`list->bits`

, with a reversed bit order (LSB first) (see ビット演算).

- Function:
**booleans->integer***bool …* [SRFI-60] {

`srfi-60`} ≡`(list->integer (list`

`bool`…))Srfi-151 has similar procedure

`bits`

, with a reversed bit order (LSB first) (see ビット演算).

Next: オクテットベクタ, Previous: Requiring extensions, Up: ライブラリモジュール - SRFI [Contents][Index]