It's a bit difficult to work with Real (in z3, not z3-sys) since the only provided way to get a value out at the end is Real::as_real(&self) -> Option<(i64, i64)>, which really only works for rational numbers. In this PR I've added two new functions to help:
Real::approx(&self, precision: usize) -> ::std::string::String, which gives a string approximation of the real value up to precision correct digits after the decimal (via Z3_get_numeral_decimal_string).
Real::approx_f64(&self) -> f64, which is just a convenience wrapper for self.approx(17).parse().unwrap() to get a full-precision f64 approximation of the real number.
I also noticed that tests/objectives.rs, tests/ops.rs, and tests/semver_tests.rs weren't actually having their tests executed since they weren't linked into the lib, so I declared them as (test) modules. It looks like some of those are failing, but that's not something that this PR caused.
It's a bit difficult to work with
Real
(inz3
, notz3-sys
) since the only provided way to get a value out at the end isReal::as_real(&self) -> Option<(i64, i64)>
, which really only works for rational numbers. In this PR I've added two new functions to help:Real::approx(&self, precision: usize) -> ::std::string::String
, which gives a string approximation of the real value up toprecision
correct digits after the decimal (viaZ3_get_numeral_decimal_string
).Real::approx_f64(&self) -> f64
, which is just a convenience wrapper forself.approx(17).parse().unwrap()
to get a full-precisionf64
approximation of the real number.I also noticed that
tests/objectives.rs
,tests/ops.rs
, andtests/semver_tests.rs
weren't actually having their tests executed since they weren't linked into the lib, so I declared them as (test) modules. It looks like some of those are failing, but that's not something that this PR caused.