fact: Definition IQmake_to_decimal num den := let num := Z.to_int num in let (den, e_den) := Decimal.nztail (Pos.to_uint den) in match den with | Decimal.D1 Decimal.Nil => match e_den with | O => Some (Decimal.Decimal num Decimal.Nil) | ne => let ai := Decimal.abs num in let ni := Decimal.nb_digits ai in if Nat.ltb ne ni then let i := Decimal.del_tail_int ne num in let f := Decimal.del_head (Nat.sub ni ne) ai in Some (Decimal.Decimal i f) else let z := match num with | Decimal.Pos _ => Decimal.Pos (Decimal.zero) | Decimal.Neg _ => Decimal.Neg (Decimal.zero) end in Some (Decimal.Decimal z (Nat.iter (Nat.sub ne ni) Decimal.D0 ai)) end | _ => None end.
imports: ZArith_base ZArithRing ZArith.BinInt Morphisms Setoid Bool