BitVecSignedCompare
- Function
- August 22, 2025
Table of Contents
BitVecSignedCompare
BitVecSignedCompare
Description
Compare two bitvectors as signed integers (MSB is sign bit).
Parameters
Name | Direction | Description |
---|---|---|
bv1 | in | First bitvector |
bv2 | in | Second bitvector |
Usage example (from documentation)
int result = BitVecSignedCompare(&flags1, &flags2);
Usage example (Cross-references)
- In
BitVec.c:628
:
}
int BitVecSignedCompare(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);
// Test BitVecSignedCompare function
bool test_bitvec_signed_compare(void) {
printf("Testing BitVecSignedCompare\n");
BitVec bv1 = BitVecInit();
// Positive should be greater than negative
bool result = (BitVecSignedCompare(&bv1, &bv2) > 0);
// Test two positives
// 3 > 1
result = result && (BitVecSignedCompare(&bv1, &bv2) > 0);
// Test equal signed values
// Test equal signed values
BitVec bv3 = BitVecClone(&bv1);
result = result && (BitVecSignedCompare(&bv1, &bv3) == 0);
// Clean up
// Signed: 01111111 (+127) > 10000001 (-127)
result = result && (BitVecSignedCompare(&pos, &neg) > 0);
// Clean up