BitVecXor

Table of Contents

BitVecXor

Description

Perform bitwise XOR operation between two bitvectors. Result is stored in the first bitvector.

Parameters

NameDirectionDescription
resultoutBitvector to store result in
ainFirst bitvector operand
binSecond bitvector operand

Usage example (from documentation)

  BitVecXor(&result, &flags1, &flags2);

Usage example (Cross-references)

    }
    
    void BitVecXor(BitVec *result, BitVec *a, BitVec *b) {
    ValidateBitVec(result);
    ValidateBitVec(a);
    
    // Test NULL second operand - should abort
    BitVecXor(&result, NULL, &bv1);
    
    BitVecDeinit(&result);
    // Test BitVecXor function
    bool test_bitvec_xor(void) {
    WriteFmt("Testing BitVecXor\n");
    
    BitVec bv1    = BitVecInit();
    
    // Perform XOR operation
    BitVecXor(&result, &bv1, &bv2);
    
    // Expected result: 0110 (1100 XOR 1010)
    
    // Test XOR with different lengths
    BitVecXor(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 8);
    
    // Test A XOR A = 0
    BitVecXor(&result, &bv1, &bv1);
    test_result = test_result && (result.length == 16);
    for (int i = 0; i < 16; i++) {
    
    // Test A XOR B = B XOR A
    BitVecXor(&result1, &bv1, &bv2);
    BitVecXor(&result2, &bv2, &bv1);
    // Test A XOR B = B XOR A
    BitVecXor(&result1, &bv1, &bv2);
    BitVecXor(&result2, &bv2, &bv1);
    
    bool xor_commutative = true;
    
    // Test XOR on large data
    BitVecXor(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 1000);
    // Test BitVecXor function
    bool test_bitvec_xor(void) {
    WriteFmtLn("Testing BitVecXor");
    
    BitVec bv1    = BitVecInit();
    
    // Perform XOR operation
    BitVecXor(&result, &bv1, &bv2);
    
    // Expected result: 0110 (1100 XOR 1010)
    
    // Test XOR with different lengths
    BitVecXor(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 8);
    
    // Test A XOR A = 0
    BitVecXor(&result, &bv1, &bv1);
    test_result = test_result && (result.length == 16);
    for (int i = 0; i < 16; i++) {
    
    // Test A XOR B = B XOR A
    BitVecXor(&result1, &bv1, &bv2);
    BitVecXor(&result2, &bv2, &bv1);
    // Test A XOR B = B XOR A
    BitVecXor(&result1, &bv1, &bv2);
    BitVecXor(&result2, &bv2, &bv1);
    
    bool xor_commutative = true;
    
    // Test XOR on large data
    BitVecXor(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 1000);
    
    // Test NULL second operand - should abort
    BitVecXor(&result, NULL, &bv1);
    
    BitVecDeinit(&result);

Share :

Related Posts

BitVecIsSorted

BitVecIsSorted Description Check if bits in bitvector are in sorted order. Useful for certain algorithms and data structures.

Read More

BitVecOverlaps

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

Read More

BitVecDisjoint

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

Read More