Core.PercentSourceA scale factor, not bounded between 0% and 100%, represented as a float.
Exposing that this is a float allows for more optimization. E.g. compiler can optimize some local refs and not box them.
of_string and t_of_sexp disallow nan, inf, etc.
Sexps are of the form 5bp or 0.05% or 0.0005x.
Warning: equal (t) (t_of_sexp (sexp_of_t t)) is not guaranteed. Multiple serialization round-trips may cause multiple small drifts.
include Interfaces.Binable with type t := tinclude Bin_prot.Binable.S_only_functions with type t := tThis function only needs implementation if t exposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the variant t afterwards.
include Interfaces.Comparable_binable with type t := tinclude Base.Comparable.S with type t := tinclude Base.Comparisons.S with type t := tcompare t1 t2 returns 0 if t1 is equal to t2, a negative integer if t1 is less than t2, and a positive integer if t1 is greater than t2.
ascending 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).
include Base.Comparator.S with type t := tinclude Comparator.S
with type t := t
with type comparator_witness := comparator_witnessmodule Map :
Map.S_binable
with type Key.t = t
with type Key.comparator_witness = comparator_witnessmodule Set :
Set.S_binable
with type Elt.t = t
with type Elt.comparator_witness = comparator_witnessapply t x multiplies the percent t by x, returning a float.
scale t x scales the percent t by x, returning a new t.
of_mult 5. is 5x = 500% = 50_000bp
of_percentage 5. is 5% = 0.05x = 500bp
of_bp 5. is 5bp = 0.05% = 0.0005x
rounds down
0.0123456% ~significant_digits:4 is 1.235bp
0.0123456% ~decimal_digits:4 is 0.0001 = 1bp
0.0123456% ~decimal_digits:4 is 0.0123% = 1.23bp
0.0123456% ~decimal_digits:4 is 1.2346bp
A Format.t tells Percent.format how to render a floating-point value as a string, like a printf conversion specification.
The sign of a Percent.t. Both -0. and 0. map to Zero. Raises on nan. All other values map to Neg or Pos.
Does not format small values as "3bp" or large ones as "2x"; always uses percentages ("0.0003%" or "200%"). The standard of_sexp can read these just fine.