aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/IEEE754_extra.v11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/IEEE754_extra.v b/lib/IEEE754_extra.v
index b0d1944e..d2372f17 100644
--- a/lib/IEEE754_extra.v
+++ b/lib/IEEE754_extra.v
@@ -879,6 +879,17 @@ Proof.
unfold ZofB_range. rewrite D. rewrite Zle_bool_true by lia. rewrite Zle_bool_true by lia. auto.
Qed.
+(** ZofB_ne : convert float to integer, round to nearest *)
+
+Definition Zdiv_ne (a b : Z) :=
+ let q := Z.div a b in
+ let q1 := Z.succ q in
+ match Z.compare (a-b*q) (b*q1-a) with
+ | Lt => q
+ | Gt => q1
+ | Eq => (if Z.even q then q else q1)
+ end.
+
(** ** Algebraic identities *)
(** Commutativity of addition and multiplication *)