BitVecOr

Table of Contents

BitVecOr

Description

Perform bitwise OR 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)

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

Usage example (Cross-references)

    }
    
    void BitVecOr(BitVec *result, BitVec *a, BitVec *b) {
    ValidateBitVec(result);
    ValidateBitVec(a);
    // Test BitVecOr function
    bool test_bitvec_or(void) {
    printf("Testing BitVecOr\n");
    
    BitVec bv1    = BitVecInit();
    
    // Perform OR operation
    BitVecOr(&result, &bv1, &bv2);
    
    // Expected result: 1110 (1100 OR 1010)
    result = result && (result_bv.length == 0);
    
    BitVecOr(&result_bv, &bv1, &bv2);
    result = result && (result_bv.length == 0);
    
    // Test OR with different lengths (result should be max length)
    BitVecOr(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 8);
    test_result = test_result && (BitVecGet(&result, 0) == false);
    
    BitVecOr(&result, &bv1, &bv2);
    test_result = test_result && (BitVecGet(&result, 0) == true);
    
    // Test A OR A = A
    BitVecOr(&result, &bv1, &bv1);
    bool or_identity = true;
    for (int i = 0; i < 16; i++) {
    }
    
    BitVecOr(&result, &bv1, &bv2);
    bool or_ones = true;
    for (int i = 0; i < 16; i++) {
    
    // Test A OR B = B OR A
    BitVecOr(&result1, &bv1, &bv2);
    BitVecOr(&result2, &bv2, &bv1);
    // Test A OR B = B OR A
    BitVecOr(&result1, &bv1, &bv2);
    BitVecOr(&result2, &bv2, &bv1);
    
    bool or_commutative = true;
    
    // Test NULL operand - should abort
    BitVecOr(&result, &bv1, NULL);
    
    BitVecDeinit(&result);
    // Test BitVecOr function
    bool test_bitvec_or(void) {
    printf("Testing BitVecOr\n");
    
    BitVec bv1    = BitVecInit();
    
    // Perform OR operation
    BitVecOr(&result, &bv1, &bv2);
    
    // Expected result: 1110 (1100 OR 1010)
    result = result && (result_bv.length == 0);
    
    BitVecOr(&result_bv, &bv1, &bv2);
    result = result && (result_bv.length == 0);
    
    // Test OR with different lengths (result should be max length)
    BitVecOr(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 8);
    test_result = test_result && (BitVecGet(&result, 0) == false);
    
    BitVecOr(&result, &bv1, &bv2);
    test_result = test_result && (BitVecGet(&result, 0) == true);
    
    // Test A OR A = A
    BitVecOr(&result, &bv1, &bv1);
    bool or_identity = true;
    for (int i = 0; i < 16; i++) {
    }
    
    BitVecOr(&result, &bv1, &bv2);
    bool or_ones = true;
    for (int i = 0; i < 16; i++) {
    
    // Test A OR B = B OR A
    BitVecOr(&result1, &bv1, &bv2);
    BitVecOr(&result2, &bv2, &bv1);
    // Test A OR B = B OR A
    BitVecOr(&result1, &bv1, &bv2);
    BitVecOr(&result2, &bv2, &bv1);
    
    bool or_commutative = true;
    
    // Test NULL operand - should abort
    BitVecOr(&result, &bv1, NULL);
    
    BitVecDeinit(&result);

Share :

Related Posts

BitVecBestAlignment

BitVecBestAlignment Description Find best overlapping alignment between two bitvectors. Returns the offset that gives the best alignment score.

Read More

BitVecAlignmentScore

BitVecAlignmentScore Description Calculate alignment score between two bitvectors. Used in bioinformatics-style sequence alignment with match/mismatch scoring.

Read More

BitVecAnd

BitVecAnd Description Perform bitwise AND operation between two bitvectors. Result is stored in the first bitvector.

Read More