sidekick/src/zarith/sidekick_zarith.ml
2021-07-03 20:20:19 -04:00

20 lines
418 B
OCaml

module Int : Sidekick_arith.INT with type t = Z.t = struct
include Z
include Z.Compare
let pp = pp_print
end
module Rational
: Sidekick_arith.RATIONAL with type t = Q.t and type bigint = Z.t
= struct
type bigint = Z.t
include Q
let denum = den
let pp = pp_print
let hash a = Hashtbl.hash (Z.hash (num a), Z.hash (den a))
let pp_approx n out q = Format.fprintf out "%*.1f" n (Q.to_float q)
end