Skip to content
BitVecTryFromInteger

BitVecTryFromInteger

Description

Build a bitvector from an integer.

This public API supports both forms:

  • BitVecTryFromInteger(out, value, bits)
  • BitVecTryFromInteger(out, value, bits, alloc)

Omitting the allocator binds the destination to DefaultAllocator().

Success

Returns true and initializes out.

Failure

Returns false if allocation fails.

Usage example (Cross-references)

Usage examples (Cross-references)
        u64    value = 11; // 1011 in binary
        BitVec bv;
        bool   ok = BitVecTryFromInteger(&bv, value, 4);
    
        // Check result
        // Test with zero
        BitVec zero_bv;
        result = result && BitVecTryFromInteger(&zero_bv, 0, 8);
        result = result && (zero_bv.length == 8);
Last updated on