mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 02:45:51 +00:00
add method to create bit-vectors directly from an array of Booleans
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
2c97eb1393
commit
795e0c641a
7 changed files with 45 additions and 15 deletions
|
@ -3127,6 +3127,20 @@ namespace Microsoft.Z3
|
|||
|
||||
return (BitVecNum)MkNumeral(v, MkBitVecSort(size));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a bit-vector numeral.
|
||||
/// </summary>
|
||||
/// <param name="bits">An array of bits representing the bit-vector. Least signficant bit is at position 0.</param>
|
||||
public BitVecNum MkBV(bool[] bits)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BitVecNum>() != null);
|
||||
int[] _bits = new int[bits.Length];
|
||||
for (int i = 0; i < bits.Length; ++i) _bits[i] = bits[i] ? 1 : 0;
|
||||
return (BitVecNum)Expr.Create(this, Native.Z3_mk_bv_numeral(nCtx, (uint)bits.Length, _bits));
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Numerals
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue