(** This file is part of the Flocq formalization of floating-point arithmetic in Coq: http://flocq.gforge.inria.fr/  Copyright (C) 2010-2013 Sylvie Boldo #<br /># Copyright (C) 2010-2013 Guillaume Melquiond  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details. *)
(** * Rounding to odd and its properties, including the equivalence between rnd_NE and double rounding with rnd_odd and then rnd_NE *)
Definition Zrnd_odd x :=  match Req_EM_T x (Z2R (Zfloor x))  with
| left _   => Zfloor x
| right _  => match (Zeven (Zfloor x)) with
| true => Zceil x
| false => Zfloor x
end
end.
Global Instance valid_rnd_odd : Valid_rnd Zrnd_odd.

(* Specifications: *)
Lemma Zrnd_odd_Zodd: forall x, x <> (Z2R (Zfloor x)) ->
(Zeven (Zrnd_odd x)) = false.
Lemma Zrnd_odd_Zodd: forall x, x <> (Z2R (Zfloor x)) ->
(Zeven (Zrnd_odd x)) = false.