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

Added FP to_ieee_bv to fpa_rewriter to enable model evaluation.

This commit is contained in:
Christoph M. Wintersteiger 2015-09-16 12:57:05 +01:00
parent 46e24e094c
commit 79d69cd5f0
8 changed files with 71 additions and 16 deletions

View file

@ -1179,6 +1179,19 @@ void mpf_manager::to_sbv_mpq(mpf_rounding_mode rm, const mpf & x, scoped_mpq & o
if (x.sign) m_mpq_manager.neg(o);
}
void mpf_manager::to_ieee_bv_mpz(const mpf & x, scoped_mpz & o) {
SASSERT(!is_nan(x) && !is_inf(x));
SASSERT(exp(x) < INT_MAX);
unsigned sbits = x.get_sbits();
unsigned ebits = x.get_ebits();
m_mpz_manager.set(o, sgn(x));
m_mpz_manager.mul2k(o, ebits);
m_mpz_manager.add(o, exp(x), o);
m_mpz_manager.mul2k(o, sbits - 1);
m_mpz_manager.add(o, sig(x), o);
}
void mpf_manager::rem(mpf const & x, mpf const & y, mpf & o) {
SASSERT(x.sbits == y.sbits && x.ebits == y.ebits);

View file

@ -207,6 +207,7 @@ public:
unsigned prev_power_of_two(mpf const & a);
void to_sbv_mpq(mpf_rounding_mode rm, const mpf & x, scoped_mpq & o);
void to_ieee_bv_mpz(const mpf & x, scoped_mpz & o);
protected:
void mk_one(unsigned ebits, unsigned sbits, bool sign, mpf & o) const;