mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 11:15:43 -05:00
feat: add Q.is_int
This commit is contained in:
parent
2bce3e6dd9
commit
02a9abde3e
2 changed files with 4 additions and 0 deletions
|
|
@ -53,6 +53,9 @@ module type RATIONAL = sig
|
|||
val is_real : t -> bool
|
||||
(** A proper real, not nan/infinity *)
|
||||
|
||||
val is_int : t -> bool
|
||||
(** Is this a proper integer? *)
|
||||
|
||||
val pp_approx : int -> Format.formatter -> t -> unit
|
||||
(** Pretty print rational with given amount of precision
|
||||
(for example as a floating point number) *)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ module Rational
|
|||
let infinity = Q.inf
|
||||
let minus_infinity = Q.minus_inf
|
||||
let is_real = Q.is_real
|
||||
let is_int q = is_real q && Z.(equal (denum q) one)
|
||||
|
||||
let pp_approx n out q = Format.fprintf out "%*.1f" n (Q.to_float q)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue