src/bitvector.c
/*  Test if two bit vectors are equal.  */
Test if two bit vectors are equal.
Test if two bit vectors are equal .
boolean
bits_are_equal (bit_vector *b, bit_vector *c)
{
    int full_words = b->num_bits / WORDBITS;
    int excess_bits = b->num_bits % WORDBITS;
    unsigned mask = (((unsigned)1) << excess_bits) - 1;
    int i;
    assert(b->num_bits == c->num_bits);
    for (i = 0; i < full_words; i++) {
        if (b->bits[i] != c->bits[i]) return FALSE;
    }
    if (excess_bits) {
        if ((b->bits[full_words] & mask) != (c->bits[full_words] & mask)) {
            return FALSE;
        }
    }
    return TRUE;
}
boolean bits_are_equal ( bit_vector * b , bit_vector * c ) { int full_words = b -> num_bits / WORDBITS ; int excess_bits = b -> num_bits % WORDBITS ; unsigned mask = ( ( ( unsigned ) 1 ) << excess_bits ) - 1 ; int i ; assert ( b -> num_bits == c -> num_bits ) ; for ( i = 0 ; i < full_words ; i ++ ) { if ( b -> bits [ i ] != c -> bits [ i ] ) return FALSE ; } if ( excess_bits ) { if ( ( b -> bits [ full_words ] & mask ) != ( c -> bits [ full_words ] & mask ) ) { return FALSE ; } } return TRUE ; }
Test if two bit vectors are equal.
Test if two bit vectors are equal .
/* check everything but the last word */ /* check the remaining bits */