We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 42bae5f commit bfc059fCopy full SHA for bfc059f
z3/src/ast.rs
@@ -946,6 +946,20 @@ impl<'ctx> Real<'ctx> {
946
self.approx(17).parse().unwrap() // 17 decimal digits needed to get full f64 precision
947
}
948
949
+ pub fn exact_f64(&self) -> Option<f64> {
950
+ let res = unsafe { Z3_get_numeral_double(self.get_ctx().z3_ctx, self.z3_ast) };
951
+ if res == 0.0 {
952
+ let mut sacrifice_int = 0;
953
+ let int_res = unsafe {
954
+ Z3_get_numeral_int(self.get_ctx().z3_ctx, self.z3_ast, &mut sacrifice_int)
955
+ };
956
+ if !int_res || sacrifice_int != 0 {
957
+ return None;
958
+ }
959
960
+ Some(res)
961
962
+
963
pub fn from_int(ast: &Int<'ctx>) -> Real<'ctx> {
964
unsafe { Self::wrap(ast.ctx, Z3_mk_int2real(ast.ctx.z3_ctx, ast.z3_ast)) }
965
0 commit comments