• egg

## Documentation

### logical-shift-left

[procedure] (logical-shift-left N1 N2) --> integer

Returns left shift of N1 by N2 bits.

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

Aliases arithmetic-shift.

### logical-shift-right

[procedure] (logical-shift-right N1 N2) --> integer

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

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

### arithmetic-shift-left

[procedure] (arithmetic-shift-left N1 N2) --> integer

Returns left shift of N1 by N2 bits.

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

Aliases arithmetic-shift.

### arithmetic-shift-right

[procedure] (arithmetic-shift-right N1 N2) --> integer

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

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

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

[procedure] (bitwise-mask WID [ON?]) --> integer

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

[procedure] (bitwise-join N0 [N1 ...]) --> integer

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

### bitwise-split

[procedure] (bitwise-split N WID) --> (list-of integer)

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

[procedure] (bitwise-count N) --> fixnum

Returns number of set bits in N.

N
integer

### bitwise-merge

[procedure] (bitwise-merge MASK N0 N1) --> integer
integer
N0
integer
N1
integer

Renamed SRFI-60 bitwise-if.

### bitwise-nth?

[procedure] (bitwise-nth? INDEX N) --> boolean
INDEX
integer
N
fixnum

Renamed SRFI-60 bit-set?.

### bitwise-any?

[procedure] (bitwise-any? N1 N2) --> boolean
N1
integer
N2
integer

Renamed SRFI-60 any-bits-set?.

### bitwise-first-set

[procedure] (bitwise-first-set N) --> fixnum
N
integer

Renamed SRFI-60 first-set-bit.

### bitwise-reverse

[procedure] (bitwise-reverse N K) --> integer
N
integer
K
fixnum

### bitwise-rotate

[procedure] (bitwise-rotate K COUNT LEN) --> integer

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

K
integer
COUNT
fixnum
LEN
fixnum

### bitwise-set-nth

[procedure] (bitwise-set-nth TO INDEX ON?) --> integer
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

[procedure] (bitwise-field N START END) --> integer
N
integer
START
fixnum
END
fixnum

Renamed SRFI-60 bit-field.

### bitwise-field-copy

[procedure] (bitwise-field-copy TO FROM START END) --> integer
TO
integer
FROM
integer
START
fixnum
END
fixnum

Renamed SRFI-60 copy-bit-field.

### bitwise-field-reverse

[procedure] (bitwise-field-reverse N START END) --> integer
N
integer
START
fixnum
END
fixnum

Renamed SRFI-60 reverse-bit-field.

[procedure] (bitwise-field-rotate N COUNT START END) --> integer
N
integer
COUNT
fixnum
START
fixnum
END
fixnum

Renamed SRFI-60 rotate-bit-field.

### integer->list

[procedure] (integer->list K [LEN]) --> (list-of boolean)
K
integer ; integer to represent as a bit list.
LEN
fixnum ; number of bits, default is all bits.

### list->integer

[procedure] (list->integer BOOLS) --> integer
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