BitVecNot

Table of Contents

BitVecNot

Description

Perform bitwise NOT operation on a bitvector. Result is stored in the first bitvector.

Parameters

NameDirectionDescription
resultoutBitvector to store result in
bvinBitvector operand

Usage example (from documentation)

  BitVecNot(&result, &flags);

Usage example (Cross-references)

    }
    
    void BitVecNot(BitVec *result, BitVec *bitvec) {
    ValidateBitVec(result);
    ValidateBitVec(bitvec);
    // Test BitVecNot function
    bool test_bitvec_not(void) {
    printf("Testing BitVecNot\n");
    
    BitVec bv     = BitVecInit();
    
    // Perform NOT operation
    BitVecNot(&result, &bv);
    
    // Expected result: 0101 (NOT 1010)
    // Test NOT on various sizes
    BitVecClear(&bv1);
    BitVecNot(&result_bv, &bv1);
    result = result && (result_bv.length == 0);
    
    BitVecPush(&bv1, true);
    BitVecNot(&result_bv, &bv1);
    result = result && (BitVecGet(&result_bv, 0) == false);
    }
    
    BitVecNot(&result, &bv1);
    test_result = test_result && (result.length == 100);
    
    // Test NOT(NOT(A)) = A
    BitVecNot(&result, &bv1);    // result = NOT(A)
    BitVecNot(&result, &result); // result = NOT(NOT(A))
    // Test NOT(NOT(A)) = A
    BitVecNot(&result, &bv1);    // result = NOT(A)
    BitVecNot(&result, &result); // result = NOT(NOT(A))
    
    bool double_not = true;
    
    // Test NOT on large data
    BitVecNot(&result, &bv1);
    test_result = test_result && (result.length == 1000);
    
    // Test NULL operand - should abort
    BitVecNot(&result, NULL);
    
    BitVecDeinit(&result);
    // Test BitVecNot function
    bool test_bitvec_not(void) {
    printf("Testing BitVecNot\n");
    
    BitVec bv     = BitVecInit();
    
    // Perform NOT operation
    BitVecNot(&result, &bv);
    
    // Expected result: 0101 (NOT 1010)
    // Test NOT on various sizes
    BitVecClear(&bv1);
    BitVecNot(&result_bv, &bv1);
    result = result && (result_bv.length == 0);
    
    BitVecPush(&bv1, true);
    BitVecNot(&result_bv, &bv1);
    result = result && (BitVecGet(&result_bv, 0) == false);
    }
    
    BitVecNot(&result, &bv1);
    test_result = test_result && (result.length == 100);
    
    // Test NOT(NOT(A)) = A
    BitVecNot(&result, &bv1);    // result = NOT(A)
    BitVecNot(&result, &result); // result = NOT(NOT(A))
    // Test NOT(NOT(A)) = A
    BitVecNot(&result, &bv1);    // result = NOT(A)
    BitVecNot(&result, &result); // result = NOT(NOT(A))
    
    bool double_not = true;
    
    // Test NOT on large data
    BitVecNot(&result, &bv1);
    test_result = test_result && (result.length == 1000);
    
    // Test NULL operand - should abort
    BitVecNot(&result, NULL);
    
    BitVecDeinit(&result);

Share :

Related Posts

BitVecEntropy

BitVecEntropy Description Calculate information entropy of a bitvector. Entropy measures the randomness/information content of the bit pattern.

Read More

BitVecAnd

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

Read More

BitVecAlignmentScore

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

Read More