Notation bpow e := (bpow beta e).(** Computes a mantissa of precision p, the corresponding exponent,
    and the position with respect to the real quotient of the
    input floating-point numbers.

The algorithm performs the following steps:
- Shift dividend mantissa so that it has at least p2 + p digits.
- Perform the Euclidean division.
- Compute the position according to the division remainder.

Complexity is fine as long as p1 <= 2p and p2 <= p.
*)

Definition Fdiv_core prec m1 e1 m2 e2 :=
  let d1 := Zdigits beta m1 in
  let d2 := Zdigits beta m2 in
  let e := (e1 - e2)%Z in
  let (m, e') :=
    match (d2 + prec - d1)%Z with
    | Zpos p => (m1 * Zpower_pos beta p, e + Zneg p)%Z
    | _ => (m1, e)
    end in
  let '(q, r) :=  Zdiv_eucl m m2 in
  (q, e', new_location m2 r loc_Exact).

(* Specifications: *)
Theorem Fdiv_core_correct : forall prec m1 e1 m2 e2, (0 < prec)%Z -> (0 < m1)%Z -> (0 < m2)%Z -> let '(m, e, l) := Fdiv_core prec m1 e1 m2 e2 in (prec <= Zdigits beta m)%Z /\ inbetween_float beta m e (F2R (Float beta m1 e1) / F2R (Float beta m2 e2)) l.