Up

module Bignum0

: sig

Arbitrary-precision rational numbers.

#
type t
include Core_kernel.Std.Sexpable with type t := t
include Core_kernel.Std.Comparable with type t := t
include Core_kernel.Std.Floatable with type t := t
include Core_kernel.Std.Hashable with type t := t
include Core_kernel.Std.Binable with type t := t
#
val zero : t
#
val one : t
#
val ten : t
#
val hundred : t
#
val thousand : t
#
val million : t
#
val billion : t
#
val trillion : t
#
val tenth : t
#
val hundredth : t
#
val thousandth : t
#
val millionth : t
#
val billionth : t
#
val trillionth : t
#
val (+) : t -> t -> t
#
val (-) : t -> t -> t
#
val (/) : t -> t -> t
#
val (*) : t -> t -> t

Beware: 2 ** 8_000_000 will take at least a megabyte to store the result, and multiplying numbers a megabyte long is slow no matter how clever your algorithm. Be careful to ensure the second argument is reasonably-sized.

#
val (**) : t -> int -> t
#
val abs : t -> t
#
val neg : t -> t
#
val inverse : t -> t
#
val sum : t list -> t
#
val round : ?dir:[
| `Down
| `Up
| `Nearest
| `Zero
] -> ?to_multiple_of:t -> t -> t

Default rounding direction is `Nearest. to_multiple_of defaults to one and must not be zero.

#
val iround : ?dir:[
| `Down
| `Up
| `Nearest
| `Zero
] -> ?to_multiple_of:int -> t -> int option

None if the result would overflow or to_multiple_of is zero.

#
val round_as_bigint : ?dir:[
| `Down
| `Up
| `Nearest
| `Zero
] -> ?to_multiple_of:Bigint.t -> t -> Bigint.t option
#
val iround_exn : ?dir:[
| `Down
| `Up
| `Nearest
| `Zero
] -> ?to_multiple_of:int -> t -> int

Exception if the result would overflow or to_multiple_of is zero.

#
val round_as_bigint_exn : ?dir:[
| `Down
| `Up
| `Nearest
| `Zero
] -> ?to_multiple_of:Bigint.t -> t -> Bigint.t
#
val round_decimal : ?dir:[
| `Down
| `Up
| `Nearest
| `Zero
] -> digits:int -> t -> t

Convenience wrapper around round to round to the specified number of decimal digits.

#
val to_string : t -> string

Decimal. Output is truncated (not rounded) to nine decimal places, so may be lossy. Consider using sexp_of_t if you need lossless stringification.

#
val to_float : t -> float

Rounds toward zero. None if the conversion would overflow

#
val to_int : t -> int option
#
val to_int_exn : t -> int
#
val is_zero : t -> bool
#
val sign : t -> int
#
val of_string : string -> t
#
val of_int : int -> t
#
val of_float : float -> t
#
val num : t -> t

num t returns the numerator of the numeric

#
val den : t -> t

den t returns the denominator of the numeric

#
val of_bigint : Bigint.t -> t
#
val num_as_bigint : t -> Bigint.t
#
val den_as_bigint : t -> Bigint.t
#
val pp : Format.formatter -> t -> unit
#
module Stable : sig
#
module V1 : sig
include sig
#
type __pa_nonrec_0 = t
#
type t = __pa_nonrec_0
end
with type __pa_nonrec_0 := t
#
val compare : t -> t -> int
#
val bin_t : t Core_kernel.Std.Bin_prot.Type_class.t
#
val bin_read_t : t Core_kernel.Std.Bin_prot.Read.reader
#
val __bin_read_t__ : (int -> t) Core_kernel.Std.Bin_prot.Read.reader
#
val bin_reader_t : t Core_kernel.Std.Bin_prot.Type_class.reader
#
val bin_size_t : t Core_kernel.Std.Bin_prot.Size.sizer
#
val bin_write_t : t Core_kernel.Std.Bin_prot.Write.writer
#
val bin_writer_t : t Core_kernel.Std.Bin_prot.Type_class.writer
#
val t_of_sexp : Sexplib.Sexp.t -> t
#
val sexp_of_t : t -> Sexplib.Sexp.t
end
#
module V2 : sig
include sig
#
type __pa_nonrec_1 = t
#
type t = __pa_nonrec_1
end
with type __pa_nonrec_1 := t
#
val compare : t -> t -> int
#
val bin_t : t Core_kernel.Std.Bin_prot.Type_class.t
#
val bin_read_t : t Core_kernel.Std.Bin_prot.Read.reader
#
val __bin_read_t__ : (int -> t) Core_kernel.Std.Bin_prot.Read.reader
#
val bin_reader_t : t Core_kernel.Std.Bin_prot.Type_class.reader
#
val bin_size_t : t Core_kernel.Std.Bin_prot.Size.sizer
#
val bin_write_t : t Core_kernel.Std.Bin_prot.Write.writer
#
val bin_writer_t : t Core_kernel.Std.Bin_prot.Type_class.writer
#
val t_of_sexp : Sexplib.Sexp.t -> t
#
val sexp_of_t : t -> Sexplib.Sexp.t
end
end
#
module O : sig
#
val (+) : t -> t -> t
#
val (-) : t -> t -> t
#
val (/) : t -> t -> t
#
val (*) : t -> t -> t
#
val (**) : t -> int -> t
#
val abs : t -> t
#
val neg : t -> t
include Core_kernel.Polymorphic_compare_intf.Infix with type t := t
#
val zero : t
#
val one : t
#
val ten : t
#
val hundred : t
#
val thousand : t
#
val million : t
#
val billion : t
#
val trillion : t
#
val tenth : t
#
val hundredth : t
#
val thousandth : t
#
val millionth : t
#
val billionth : t
#
val trillionth : t
#
val of_int : int -> t
#
val of_float : float -> t
end
end