BitVecCompareRange
Description
Compare ranges of two bitvectors lexicographically.
Parameters
| Name | Direction | Description |
|---|---|---|
bv1 |
in | First bitvector |
start1 |
in | Starting position in first bitvector |
bv2 |
in | Second bitvector |
start2 |
in | Starting position in second bitvector |
len |
in | Number of bits to compare |
Usage example (from documentation)
int result = BitVecCompareRange(&bv1, 5, &bv2, 10, 8);Success
-1 if bv1 < bv2, 0 if equal, 1 if bv1 > bv2
Failure
Aborts via the validator if either range exceeds its bitvector’s length.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
BitVec.c:716:
u64 min_len = MIN2(bv1->length, bv2->length);
int range_result = BitVecCompareRange(bv1, 0, bv2, 0, min_len);
if (range_result != 0) {
return range_result;- In
BitVec.c:732:
}
int BitVecCompareRange(const BitVec *bv1, u64 start1, const BitVec *bv2, u64 start2, u64 len) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
Compare.c:537:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecCompareRange\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Compare.c:564:
// 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
- In
Compare.c:568:
// Test equal ranges
cmp_result = BitVecCompareRange(&bv1, 0, &bv1, 0, 8); // Self-comparison
result = result && (cmp_result == 0);- In
Compare.c:572:
// Test zero-length ranges
cmp_result = BitVecCompareRange(&bv1, 0, &bv2, 0, 0);
result = result && (cmp_result == 0); // Zero-length ranges are equal
- In
Compare.c:1276:
BitVecPush(&bv, true);
BitVecCompareRange(NULL, 0, &bv, 0, 1); // must abort
BitVecDeinit(&bv);- In
Compare.c:1291:
BitVecPush(&bv, true);
BitVecCompareRange(&bv, 0, NULL, 0, 1); // must abort
BitVecDeinit(&bv);
Last updated on