3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

add visitor example, fix double conversion

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-10-11 12:36:20 -07:00
parent 4fc64ab578
commit a990e7f02e
2 changed files with 29 additions and 12 deletions

View file

@ -239,13 +239,21 @@ extern "C" {
expr* e = to_expr(a);
fpa_util & fu = mk_c(c)->fpautil();
scoped_mpf tmp(fu.fm());
if (!mk_c(c)->fpautil().is_numeral(e, tmp) ||
tmp.get().get_ebits() > 11 ||
tmp.get().get_sbits() > 53) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return NAN;
if (mk_c(c)->fpautil().is_numeral(e, tmp)) {
if (tmp.get().get_ebits() > 11 ||
tmp.get().get_sbits() > 53) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return NAN;
}
return fu.fm().to_double(tmp);
}
return fu.fm().to_double(tmp);
rational r;
arith_util & u = mk_c(c)->autil();
if (u.is_numeral(e, r)) {
return r.get_double();
}
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return 0.0;
}
Z3_string Z3_API Z3_get_numeral_decimal_string(Z3_context c, Z3_ast a, unsigned precision) {