Next Previous Contents

9. Package for work with bit strings

The package for work with bit strings is used to implement package `IEEE'. But of course the package can be used for solving other tasks.

Here a bit is given by address (start address) of byte from which counting bits starts and its displacement which is any non negative number of bit from the start address. The most significant bit of the start address byte has number 0. The bit string is given by its first bit and its length in bits.

The interface part of the package is file `bits.h'. The implementation part is file `bits.c'. The interface contains the following external definitions of macros and functions:

Macro `BIT'

          `BIT(start_byte, bit_displacement)'
          
returns given bit value as integer value `0' or `1'. There is macro `SET_BIT (start_byte, bit_displacement, bit) for changing value of a bit. Parameter `bit' must have value `0' or `1'.

Function `is_zero_bit_string'

          `int is_zero_bit_string (const void *start_byte,
                                   int bit_displacement,
                                   int bit_length)'
          
returns `1' if given bit string contains only zero value bits, 0 otherwise.

Function `bit_string_set'

          `void bit_string_set (void *start_byte, int
                                bit_displacement, int bit,
                                int bit_length)'
          
sets up new value of all bits of given bit string. This function is bit string analog of standard C function `memset'.

Function `bit_string_copy'

          `void bit_string_copy (void *to, int to_bit_displacement,
                                 const void *from,
                                 int from_bit_displacement,
                                 int bit_length)'
          
copys a bit string to another bit string. The bit strings must be nonoverlapped. This function is bit string analog of standard C function `memcpy'.

Function `bit_string_move'

          void bit_string_move (void *to, int to_bit_displacement,
                                const void *from,
                                int from_bit_displacement,
                                int bit_length)'
          
copys a bit string to another bit string. The bit strings can be overlapped. This function is bit string analog of standard C function `memmove'.

Function `bit_string_comparison'

          `int bit_string_comparison
               (const void *str1, int bit_displacement1,
                const void *str2, int bit_displacement2,
                int bit_length)'
          
returns 0 if the bit strings are equal, 1 if the first bit string is greater than the second, -1 if the first bit string is less than the second. This function is bit string analog of standard C function `memcmp'.


Next Previous Contents