(** ** Decidable equality *)

Definition Beq_dec: forall (f1 f2: binary_float), {f1 = f2} + {f1 <> f2}.Ltac try_not_eq := try solve [right; congruence].(** ** Conversion from an integer to a FP number *)

(** Integers that can be represented exactly as FP numbers. *)

Definition integer_representable (n: Z): Prop :=
  Z.abs n <= 2^emax - 2^(emax - prec) /\ generic_format radix2 fexp (Z2R n).

(* Specifications: *)
Lemma integer_representable_n2p: forall n p, -2^prec < n < 2^prec -> 0 <= p -> p <= emax - prec -> integer_representable (n * 2^p).
Lemma integer_representable_2p: forall p, 0 <= p <= emax - 1 -> integer_representable (2^p).
Lemma integer_representable_opp: forall n, integer_representable n -> integer_representable (-n).
Lemma integer_representable_n2p_wide: forall n p, -2^prec <= n <= 2^prec -> 0 <= p -> p < emax - prec -> integer_representable (n * 2^p).
Lemma integer_representable_n: forall n, -2^prec <= n <= 2^prec -> integer_representable n.
Lemma round_int_no_overflow: forall n, Z.abs n <= 2^emax - 2^(emax-prec) -> (Rabs (round radix2 fexp (round_mode mode_NE) (Z2R n)) < bpow radix2 emax)%R.