/*
The bitstring header file
Note: the specifications for the procedures and macros are placed
in this header, because this interface is what a user of the
bitstring module sees. They may not even have access to the
implementation.
General Assumptions:
The bits of a bitstring x are numbered in string order, that is
0, 1, 2, ..., bits_length(x)-1
The length of a bitstring may vary.
An individual bit is an unsigned int of value 0 or 1. If something
other than 0 or 1 is supplied by the user as a bit, only the least
significant bit is used.
*/
/*
A bitstring is of type bits.
Invariant: at present we only permit fixed length bitstrings of
as many bits as are in an unsigned int.
*/
typedef unsigned int bits;
#define bits_length(x) ( (int) (8*sizeof(bits)))
/*
Get the length of a bitstring
Pre: none
Post: bits_length(x) is the number of bits in the bitstring x
Side Effects: none
*/
extern unsigned int bits_get (bits x, int i);
/*
Pre:
0 <= i < bits_length(x)
Post:
bits_get(x,i) is the value of bit i of x
Side effects:
none
*/
extern bits bits_put (bits x, int i, unsigned int v);
/*
Pre:
0 <= i < bits_length(x)
Post:
bits_put(x, i, v) is the same as x except that bit i is set
to the same value as bit 0 of v.
Side effects:
none
*/
extern void bits_printf (bits x);
/*
Pre:
none
Post:
none
Side Effects:
the bits of x are printed on stdout in string order,
0, 1, 2, ...
*/
#define bits_from_int(x) (x)
/*
Convert an int into a bitstring
Pre: none
Post: bits_from_int(x) is a bitstring that contains the bits of x
ordered from least significant first to most significant last.
Side Effects: none
*/