Module Core_kernel__.Byte_units
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val create : [ `Bytes | `Kilobytes | `Megabytes | `Gigabytes | `Words ] -> Core_kernel__.Import.float -> t
include Core_kernel.Comparable.S_plain with type t := t
include Core_kernel__.Comparable_intf.S_common
include Base.Comparable.S
include Base__.Comparable_intf.Polymorphic_compare
val ascending : t -> t -> int
ascending
is identical tocompare
.descending x y = ascending y x
. These are intended to be mnemonic when used likeList.sort ~compare:ascending
andList.sort ~cmp:descending
, since they cause the list to be sorted in ascending or descending order, respectively.
val descending : t -> t -> int
val between : t -> low:t -> high:t -> bool
between t ~low ~high
meanslow <= t <= high
val clamp_exn : t -> min:t -> max:t -> t
clamp_exn t ~min ~max
returnst'
, the closest value tot
such thatbetween t' ~low:min ~high:max
is true.Raises if
not (min <= max)
.
val clamp : t -> min:t -> max:t -> t Base.Or_error.t
include Base.Comparator.S with type t := t
val comparator : (t, comparator_witness) Base.Comparator.comparator
include Base__.Comparable_intf.Validate with type t := t
val validate_lbound : min:t Base.Maybe_bound.t -> t Base.Validate.check
val validate_ubound : max:t Base.Maybe_bound.t -> t Base.Validate.check
val validate_bound : min:t Base.Maybe_bound.t -> max:t Base.Maybe_bound.t -> t Base.Validate.check
module Replace_polymorphic_compare : Core_kernel__.Comparable_intf.Polymorphic_compare with type t := t
module Map : Core_kernel.Map.S_plain with type Key.t = t with type Key.comparator_witness = comparator_witness
module Set : Core_kernel.Set.S_plain with type Elt.t = t with type Elt.comparator_witness = comparator_witness
include Core_kernel.Hashable.S_plain with type t := t
include Core_kernel.Hashable.Common
val compare : t -> t -> Core_kernel__.Import.int
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.state
val hash : t -> Base.Hash.hash_value
val hashable : t Core_kernel.Hashtbl.Hashable.t
module Table : Core_kernel.Hashtbl.S_plain with type key = t
module Hash_set : Core_kernel.Hash_set.S_plain with type elt = t
module Hash_queue : Core_kernel.Hash_queue.S with type key = t
include Core_kernel__.Import.Stringable.S with type t := t
val of_bytes : Core_kernel__.Import.float -> t
This is a deprecated alias for
of_bytes_float_exn
.
val of_bytes_int : Core_kernel__.Import.int -> t
val of_bytes_int63 : Core_kernel.Int63.t -> t
val of_bytes_int64_exn : Core_kernel.Int64.t -> t
This will raise if and only if the argument can not be represented as a
Byte_units.t
. Specifically this is if the argument is outside of [-2^62,2^62).
val of_bytes_float_exn : Core_kernel__.Import.float -> t
This will raise if and only if the argument can not be represented as a
Byte_units.t
. Specifically this is if the argument is outside of [-2^62,2^62),
val of_kilobytes : Core_kernel__.Import.float -> t
create of
Byte_units
based on the number of kilobytes. N.B. This will raise if the value is outside of [-2^52,2^52).
val of_megabytes : Core_kernel__.Import.float -> t
create of
Byte_units
based on the number of Megabytes. N.B. This will raise if the value is outside of [-2^42,2^42).
val of_gigabytes : Core_kernel__.Import.float -> t
create of
Byte_units
based on the number of Gigabytes. N.B. This will raise if the value is outside of [-2^32,2^32).
val of_terabytes : Core_kernel__.Import.float -> t
create of
Byte_units
based on the number of Terabytes. N.B. This will raise if the value is outside of [-2^22,2^22).
val of_petabytes : Core_kernel__.Import.float -> t
create of
Byte_units
based on the number of Petabytes. N.B. This will raise if the value is outside of [-2^12,2^12).
val of_exabytes : Core_kernel__.Import.float -> t
create of
Byte_units
based on the number of Exabytes. N.B. This will raise if the value is outside of [-4,4).
val of_words : Core_kernel__.Import.float -> t
Do not use, consider using
of_words_int
instead. Alias forof_words_float_exn
.
val of_words_int : Core_kernel__.Import.int -> t
create of
Byte_units
based on the number of machine words.
val of_words_float_exn : Core_kernel__.Import.float -> t
Create of
Byte_units
based on the number of machine words. On 64-bit platforms this will raise if the value is outside of [-2^59,2^59). On 32-bit platforms (including JS) this will raise if the value is outside of [-2^60,2^60).
val to_string_hum : t -> Core_kernel__.Import.string
to_string_hum t
returns a string representation oft
. This will use the largest unit that will not make the translated value be below 1.For example
Byte_units.to_string_hum (Byte_units.of_bytes_int 1000)
gives1000B
, butByte_units.to_string_hum (Byte_units.of_bytes_int 1500)
gives1.46484K
.
val to_string_short : t -> Core_kernel__.Import.string
to_string_short
is liketo_string_hum
but will attempt to only show 4 significant digits.For example
Byte_units.to_string_hum (Byte_units.of_bytes_int 1000)
gives1000B
, butByte_units.to_string_hum (Byte_units.of_bytes_int 1500)
gives1.46K
.
val bytes : t -> Core_kernel__.Import.float
This is a deprecated alias for
bytes_float
.
val bytes_int_exn : t -> Core_kernel__.Import.int
This will raise if and only if the value of this
Byte_units.t
can not be represented as an int. This can only happen on platforms whereint
is less than 63 bits, specifically JS and 32-bit OCaml where this will raise if the number of bytes is outside of [-2^30,2^30).
val bytes_int63 : t -> Core_kernel.Int63.t
val bytes_int64 : t -> Core_kernel.Int64.t
val bytes_float : t -> Core_kernel__.Import.float
val kilobytes : t -> Core_kernel__.Import.float
val megabytes : t -> Core_kernel__.Import.float
val gigabytes : t -> Core_kernel__.Import.float
val terabytes : t -> Core_kernel__.Import.float
val petabytes : t -> Core_kernel__.Import.float
val exabytes : t -> Core_kernel__.Import.float
val words : t -> Core_kernel__.Import.float
Do not use, consider using
words_int_exn
instead. Alias forwords_float
val words_int_exn : t -> Core_kernel__.Import.int
In JS and on 32-bit OCaml this will raise if and only if the number of bytes is outside of [-2^32,2^32).
val words_float : t -> Core_kernel__.Import.float
val zero : t
val scale : t -> Core_kernel__.Import.float -> t
scale t mul
scale the measuret
bymul
module Infix : sig ... end
module Stable : sig ... end