mirror of
https://github.com/Z3Prover/z3
synced 2025-06-20 04:43:39 +00:00
Fixed Z3_get_numeral_double. Fixes #2501.
This commit is contained in:
parent
258b798a6b
commit
79cd1f0edc
1 changed files with 18 additions and 4 deletions
|
@ -228,8 +228,22 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
double Z3_API Z3_get_numeral_double(Z3_context c, Z3_ast a) {
|
double Z3_API Z3_get_numeral_double(Z3_context c, Z3_ast a) {
|
||||||
Z3_string s = Z3_get_numeral_decimal_string(c, a, 12);
|
LOG_Z3_get_numeral_double(c, a);
|
||||||
return std::stod(std::string(s));
|
RESET_ERROR_CODE();
|
||||||
|
if (!is_expr(a)) {
|
||||||
|
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
|
||||||
|
return 0.0/0.0;
|
||||||
|
}
|
||||||
|
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 0.0/0.0;
|
||||||
|
}
|
||||||
|
return fu.fm().to_double(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Z3_string Z3_API Z3_get_numeral_decimal_string(Z3_context c, Z3_ast a, unsigned precision) {
|
Z3_string Z3_API Z3_get_numeral_decimal_string(Z3_context c, Z3_ast a, unsigned precision) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue