Big_percentAn arbitrary-precision scale factor, not bounded between 0% and 100%.
type t = private Bignum.tinclude Ppx_compare_lib.Comparable.S with type t := tinclude Ppx_compare_lib.Comparable.S__local with type t := tinclude Ppx_compare_lib.Equal.S with type t := tinclude Ppx_compare_lib.Equal.S__local with type t := tinclude Ppx_hash_lib.Hashable.S_any with type t := tinclude Ppx_quickcheck_runtime.Quickcheckable.S with type t := tval quickcheck_generator : t Base_quickcheck.Generator.tval quickcheck_observer : t Base_quickcheck.Observer.tval quickcheck_shrinker : t Base_quickcheck.Shrinker.tval sexp_of_t : t -> Sexplib0.Sexp.tinclude Base.Comparable.S__portable with type t := tinclude Base.Comparisons.S with type t := tascending is identical to compare. descending x y = ascending y x. These are intended to be mnemonic when used like List.sort ~compare:ascending and List.sort ~cmp:descending, since they cause the list to be sorted in ascending or descending order, respectively.
clamp_exn t ~min ~max returns t', the closest value to t such that between t' ~low:min ~high:max is true.
Raises if not (min <= max).
val clamp : t -> min:t -> max:t -> t Base.Or_error.t @@ portableinclude Base.Comparator.S__portable with type t := tval comparator : (t, comparator_witness) Base.Comparator.T.comparatorval validate_lbound : min:t Core.Maybe_bound.t -> t Validate.checkval validate_ubound : max:t Core.Maybe_bound.t -> t Validate.checkval validate_bound :
min:t Core.Maybe_bound.t ->
max:t Core.Maybe_bound.t ->
t Validate.checkmodule Replace_polymorphic_compare :
Base.Comparable.Comparisons with type t := tmodule Map :
Core.Map_intf.S__portable
with type Key.t = t
with type Key.comparator_witness = comparator_witnessmodule Set :
Core.Set_intf.S__portable
with type Elt.t = t
with type Elt.comparator_witness = comparator_witnessinclude Core.Hashable.S with type t := tinclude Ppx_compare_lib.Comparable.S with type t := tinclude Ppx_hash_lib.Hashable.S_any with type t := tval hash_fold_t : t Ppx_hash_lib.hash_foldval hash : t -> Ppx_hash_lib.Std.Hash.hash_valueval hashable : t Base.Hashable.tmodule Table : Core.Hashtbl.S with type key = tmodule Hash_set : Core.Hash_set.S with type elt = tmodule Hash_queue : Core.Hash_queue.S with type key = tval zero : t @@ portableval one_hundred_percent : t @@ portableval is_zero : t -> bool @@ portableval is_nan : t -> bool @@ portableval is_inf : t -> bool @@ portableapply t x multiplies the percent t by x, returning a Bignum.t.
val of_bp_int : int -> t @@ portableof_bp_int is like of_bp, except it accepts an int instead of a Bignum.t.
val to_bp_int : t -> int option @@ portableto_bp_int t rounds down.
val to_bp_int_exn : t -> int @@ portableval of_percent_decimal : Core.Percent.t -> t @@ portableval of_percent_dyadic : Core.Percent.t -> t @@ portableval to_percent : t -> Core.Percent.t @@ portableround_decimal_mult (of_percentage 0.0123456) ~decimal_digits:4 is 0.0001 = 1bp.
round_decimal_percentage (of_percentage 0.0123456) ~decimal_digits:4 is 0.0123% = 1.23bp.
round_decimal_bp (of_percentage 0.0123456) ~decimal_digits:4 is 1.2346bp.
val sign_exn : t -> Core.Sign.t @@ portableval of_string_exn : string -> t @@ portableval of_string_allow_nan_and_inf : string -> t @@ portableval to_string_accurate : t -> string @@ portableto_string_accurate uses Bignum.to_string_accurate under the hood before appending a percent suffix (e.g. bp, x, %). If necessary, the Bignum.t representation is parenthesized.
For example:
to_string_accurate (Big_percent.of_string "1/3x") = "(33.333333333 + 1/3000000000)%"If the percent is infinite, it returns INFx or -INFx. If the percent is nan, it returns NANbp. These follow the same convention as Core.Percent.
to_string_accurate is roundtrippable with of_string_allow_nan_and_inf.
val to_string_hum :
?delimiter:char ->
?decimals:int ->
?strip_zero:bool ->
t ->
string @@ portableto_string_hum t pretty prints t in approximate decimal form, or prints INFx, -INFx, or NANbp.
For example:
to_string_hum ~delimiter:',' ~decimals:3 ~strip_zero:false 1234.1999x = "1,234.200x"No delimiters are inserted to the right of the decimal.
Note that 99.9999....% will be rounded as 100% instead of 1x and similarly for bps.
module Stable : sig ... endmodule Unstable : sig ... endmodule Always_percentage : sig ... endAlways_percentage does not format small values as 3bp or large ones as 2x, but rather always uses percentages (e.g. 0.0003% or 200%).