## Documentation

### logical-shift-left

logical-shift-left N1 N2procedure

Returns left shift of N1 by N2 bits.

N1
integer ; what to shift.
N2
fixnum ; amount to shift.

Aliases arithmetic-shift.

### logical-shift-right

logical-shift-right N1 N2procedure

Returns right shift of N1 by N2 bits. Sign preserving.

N1
integer ; what to shift.
N2
fixnum ; amount to shift.

### arithmetic-shift-left

arithmetic-shift-left N1 N2procedure

Returns left shift of N1 by N2 bits.

N1
integer ; what to shift.
N2
fixnum ; amount to shift.

Aliases arithmetic-shift.

### arithmetic-shift-right

arithmetic-shift-right N1 N2procedure

Returns right shift of N1 by N2 bits. Sign extending.

N1
integer ; what to shift.
N2
fixnum ; amount to shift.

Essentially (arithmetic-shift <> (- <>)).

Returns WID low-order bits ON?.

WID
ON?
boolean ; #t is #b1, #f is #b0; default #t.
```(bitwise-mask 5 #t) ;=> +0...011111 (#b+011111)
(bitwise-mask 5 #f) ;=> -1...100000 (#b-100000)```

### bitwise-join

(bitwise-join N0 [N1 ...]) --> integerprocedure

N0
integer ; seed.
N1 ...
integer ... ; adjoins seed left-to-right.
`(bitwise-join #b10 #b0000001 #b101) ;=> #b101101`

### bitwise-split

bitwise-split N WIDprocedure

Returns N disjoined every WID bits.

N
integer ; seed.
WID
fixnum ; bit width.
```(bitwise-split #xabcdef 4) ;=> (#xa #xb #xc #xd #xe #xf)
(bitwise-split #x-abcdef 4) ;=> (#x-a #x-b #x-c #x-d #x-e #x-f)```

### bitwise-count

bitwise-count Nprocedure

Returns number of set bits in N.

N
integer

### bitwise-merge

integer
N0
integer
N1
integer

Renamed SRFI-60 bitwise-if.

### bitwise-nth?

bitwise-nth? INDEX Nprocedure
INDEX
integer
N
fixnum

Renamed SRFI-60 bit-set?.

### bitwise-any?

bitwise-any? N1 N2procedure
N1
integer
N2
integer

Renamed SRFI-60 any-bits-set?.

### bitwise-first-set

bitwise-first-set Nprocedure
N
integer

Renamed SRFI-60 first-set-bit.

### bitwise-reverse

bitwise-reverse N Kprocedure
N
integer
K
fixnum

### bitwise-rotate

bitwise-rotate K COUNT LENprocedure

Performs (bitwise-field-rotate K COUNT 0 LEN).

K
integer
COUNT
fixnum
LEN
fixnum

### bitwise-set-nth

bitwise-set-nth TO INDEX ON?procedure
TO
integer
INDEX
fixnum
ON?
boolean ; #t is #b1, #f is #b0

Renamed SRFI-60 (copy-bit k n b); note argument order change.

### bitwise-field

bitwise-field N START ENDprocedure
N
integer
START
fixnum
END
fixnum

Renamed SRFI-60 bit-field.

### bitwise-field-copy

bitwise-field-copy TO FROM START ENDprocedure
TO
integer
FROM
integer
START
fixnum
END
fixnum

Renamed SRFI-60 copy-bit-field.

### bitwise-field-reverse

bitwise-field-reverse N START ENDprocedure
N
integer
START
fixnum
END
fixnum

Renamed SRFI-60 reverse-bit-field.

bitwise-field-rotate N COUNT START ENDprocedure
N
integer
COUNT
fixnum
START
fixnum
END
fixnum

Renamed SRFI-60 rotate-bit-field.

### integer->list

integer->list K #!optional LENprocedure
K
integer ; integer to represent as a bit list.
LEN
fixnum ; number of bits, default is all bits.

### list->integer

list->integer BOOLSprocedure
BOOLS
list ; treated as (list-of boolean-like)

### Usage

`(import bitwise-utils)`

Kon Lovett

## Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/bitwise-utils

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

## Version history

1.2.2
Fix bitwise->count.
1.2.2
Fix integer->list/list->integer so invertible.
1.2.1
.
1.2.0
Remove srfi-60 module. (Use srfi-60 egg.)
1.1.4
Fix integer->list type.
1.1.3
.
1.1.2
.
1.1.1
.
1.1.0