BitVecSignedCompare

Table of Contents

BitVecSignedCompare

Description

Compare two bitvectors as signed integers (MSB is sign bit).

Parameters

NameDirectionDescription
bv1inFirst bitvector
bv2inSecond bitvector

Usage example (from documentation)

  int result = BitVecSignedCompare(&flags1, &flags2);

Usage example (Cross-references)

    }
    
    int BitVecSignedCompare(BitVec *bv1, BitVec *bv2) {
    ValidateBitVec(bv1);
    ValidateBitVec(bv2);
    // Test BitVecSignedCompare function
    bool test_bitvec_signed_compare(void) {
    WriteFmt("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

Share :

Related Posts

BitVecOverlaps

BitVecOverlaps Description Check if two bitvectors overlap (have any common 1-bits).

Read More

BitVecNumericalCompare

BitVecNumericalCompare Description Compare two bitvectors as unsigned integers. Treats bitvectors as unsigned binary numbers (LSB first).

Read More

BitVecDisjoint

BitVecDisjoint Description Check if two bitvectors are disjoint (have no common 1-bits).

Read More