Definition general_offloat (prec emax : Z)
    (f:  Fappli_IEEE.binary_float prec emax) : option Z :=
  match f with
  | Fappli_IEEE.B754_zero _ => Some 0
  | Fappli_IEEE.B754_infinity _ => None
  | Fappli_IEEE.B754_nan _ _ => None
  | Fappli_IEEE.B754_finite s m 0 _ => Some (Fcore_Zaux.cond_Zopp s (Z.pos m))
  | Fappli_IEEE.B754_finite s m (Z.pos e) _ =>
      Some (Fcore_Zaux.cond_Zopp s (Z.pos m) * Z.pow_pos 2 e)
  | Fappli_IEEE.B754_finite s m (Z.neg e) _ =>
      Some (Fcore_Zaux.cond_Zopp s (Z.pos m / Z.pow_pos 2 e))
  end.Definition general_float_to_int (prec emax : Z) (lo hi: Z) (f: Fappli_IEEE.binary_float prec emax) : option int :=
 option_map Int.repr
   (Fappli_IEEE_extra.ZofB_range prec emax f lo hi).Goal Zoffloat = general_offloat 53 1024.Goal Zofsingle = general_offloat 24 128.Goal Float.to_int = general_float_to_int 53 1024 Int.min_signed Int.max_signed.Goal Float.to_intu = general_float_to_int 53 1024 0 Int.max_unsigned.Goal Float32.to_int = general_float_to_int 24 128 Int.min_signed Int.max_signed.Goal Float32.to_intu = general_float_to_int 24 128 0 Int.max_unsigned.

Lemma single_to_int_ok: forall f z, Zofsingle f = Some z -> Int.min_signed <= z <= Int.max_signed -> Float32.to_int f = Some (Int.repr z).