mirror of
https://github.com/Z3Prover/z3
synced 2025-05-12 10:14:42 +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
|
@ -387,4 +387,18 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(Z3_FALSE);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_bv_numeral(Z3_context c, unsigned sz, Z3_bool const* bits) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_bv_numeral(c, sz, bits);
|
||||
RESET_ERROR_CODE();
|
||||
rational r(0), two(2), one(1);
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
r *= two;
|
||||
if (bits[i]) r += one;
|
||||
}
|
||||
ast * a = mk_c(c)->mk_numeral_core(r, mk_c(c)->bvutil().mk_sort(sz));
|
||||
RETURN_Z3(of_ast(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue