Module Float.
(** ** NaN payload manipulations *)
(** The following definitions are not part of the IEEE754 standard but apply to all architectures supported by CompCert. *)
(** Transform a Nan payload to a quiet Nan payload. *)
Definition transform_quiet_nan s p H : {x :float | is_nan _ _ x = true} :=
exist _ (B754_nan 53 1024 s _ (transform_quiet_nan_proof p H)) (eq_refl true).
(** Nan payload operations for single <-> double conversions. *)
Definition expand_nan s p H : {x | is_nan 53 1024 x = true} :=
exist _ (B754_nan 53 1024 s _ (expand_nan_proof p H)) (eq_refl true).
Definition of_single_nan (f : float32) : { x : float | is_nan _ _ x = true } :=
match f with
| B754_nan s p H =>
if Archi.float_of_single_preserves_sNaN
then expand_nan s p H
else transform_quiet_nan s _ (expand_nan_proof p H)
| _ => Archi.default_nan_64
end.

Lemma reduce_nan_proof (p : positive) :
nan_pl 53 p = true ->
nan_pl 24 (Pos.shiftr_nat p 29) = true.