BitVecCompareRange

Table of Contents

BitVecCompareRange

Description

Compare ranges of two bitvectors lexicographically.

Parameters

NameDirectionDescription
bv1inFirst bitvector
start1inStarting position in first bitvector
bv2inSecond bitvector
start2inStarting position in second bitvector
leninNumber of bits to compare

Usage example (from documentation)

  int result = BitVecCompareRange(&bv1, 5, &bv2, 10, 8);

Usage example (Cross-references)

    
    // Compare common bits using range comparison
    int range_result = BitVecCompareRange(bv1, 0, bv2, 0, min_len);
    if (range_result != 0) {
    return range_result;
    }
    
    int BitVecCompareRange(BitVec *bv1, u64 start1, BitVec *bv2, u64 start2, u64 len) {
    ValidateBitVec(bv1);
    ValidateBitVec(bv2);
    // Test BitVecCompareRange function
    bool test_bitvec_compare_range(void) {
    WriteFmt("Testing BitVecCompareRange\n");
    
    BitVec bv1 = BitVecInit();
    
    // Test range comparisons
    int  cmp_result = BitVecCompareRange(&bv1, 2, &bv2, 2, 3); // Compare 3-bit ranges
    bool result     = (cmp_result != 0);                       // Should not be equal
    
    // Test equal ranges
    cmp_result = BitVecCompareRange(&bv1, 0, &bv1, 0, 8); // Self-comparison
    result     = result && (cmp_result == 0);
    
    // Test zero-length ranges
    cmp_result = BitVecCompareRange(&bv1, 0, &bv2, 0, 0);
    result     = result && (cmp_result == 0); // Zero-length ranges are equal

Share :

Related Posts

BitVecFromStr

BitVecFromStr Description Create bitvector from string representation. String should contain only ‘1’ and ‘0’ characters.

Read More

BitVecFromBytes

BitVecFromBytes Description Create bitvector from byte array. Reads the specified number of bits from the byte array.

Read More

BitVecFromInteger

BitVecFromInteger Description Create bitvector from integer value. Creates a bitvector representing the specified number of bits from the integer.

Read More