Packed_float_optionPacked_float_option.t is the moral equivalent of float option represented under the hood as a regular float where Packed_float_option.is_none = Float.is_nan.
This type is often used whenever we have code dealing with floating point numbers in code and we want to avoid allocating on the OCaml heap.
include Core.Bin_prot.Binable.S__local with type t := tinclude Bin_prot.Binable.S_only_functions__local with type t := tval bin_read_t : t Bin_prot.Read.readerval __bin_read_t__ : t Bin_prot.Read.vtag_readerThis 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.
val bin_shape_t : Bin_prot.Shape.tval bin_writer_t : t Bin_prot.Type_class.writerval bin_reader_t : t Bin_prot.Type_class.readerval bin_t : t Bin_prot.Type_class.tinclude Sexplib0.Sexpable.S with type t := tinclude Sexplib0.Sexpable.Of_sexp with type t := tval t_of_sexp : Sexplib0.Sexp.t -> tinclude Sexplib0.Sexpable.Sexp_of with type t := tval t_sexp_grammar : t Sexplib0.Sexp_grammar.t @@ portableinclude Typerep_lib.Typerepable.S with type t := tThis interface includes hash. However, the evaluation of hash t requires a comparison, and also it allocates, so this should not be used in highly performance-sensitive applications.
include Core.Immediate_option_intf.S_without_immediate_zero_alloc__local
with type t := t
and type value := floatinclude Core.Immediate_option_intf.S_without_immediate_plain_zero_alloc__local
with type t := t
with type value := floatmodule Optional_syntax : sig ... endval none : tval some_is_representable : float @ local -> Base.Bool.tval is_none : t @ local -> Base.Bool.tval is_some : t @ local -> Base.Bool.tval some : float -> tval value : t -> default:float -> floatval value_exn : t -> floatval unchecked_value : t -> floatval to_option : t -> float Base.Option.tval of_option : float Base.Option.t -> tinclude Core.Immediate_option_intf.S_derivers__local with type t := tinclude Ppx_compare_lib.Comparable.S with type t := tinclude Ppx_compare_lib.Comparable.S__local 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 sexp_of_t : t -> Sexplib0.Sexp.tinclude Typerep_lib.Typerepable.S with type t := tval typerep_of_t : t Typerep_lib.Std_internal.Typerep.t @@ portableval typename_of_t : t Typerep_lib.Typename.t @@ portableval of_or_null : float or_null -> tval to_or_null : t -> float or_nullinclude Core.Comparable.Map_and_set_binable with type t := tinclude Core.Comparator.S with type t := tval comparator : (t, comparator_witness) Base.Comparator.T.comparatormodule Map : sig ... endmodule Set : sig ... endmodule Array : sig ... endval zero : t @@ portableval value_map : t -> f:(float -> 'a) -> default:'a -> 'a @@ portableval of_float_nan_as_none : float -> t @@ portableIn some applications, float arthimetic is done where nan is used to denote an invalid value. This function can be used to interpret such results as a t with no overhead (internally, both this and unchecked_value are just the identity).
val to_float_none_as_nan : t -> float @@ portableThe result of arithmetic operations will be none if the operand is. In addition, if the float operation would give nan, the result is none.
val is_inf : t -> bool @@ portableThe result of is_inf will be: true: if operand is some inf or some -inf; false: otherwise, including when operand is none
val is_positive : t -> bool @@ portableval is_non_positive : t -> bool @@ portableval is_negative : t -> bool @@ portableval is_non_negative : t -> bool @@ portableval is_integer : t -> bool @@ portableval is_finite : t -> bool @@ portablemerge x y ~f merges together the values from x and y using f. If both x and y are None, returns none. If only one is Some, returns that one, and if both are Some, returns the result of applying f to the contents of x and y.
val validate :
none:unit Core.Validate.check ->
some:float Core.Validate.check ->
t Core.Validate.check @@ portableval validate_option_bound :
may_be_none:bool ->
?min:float Core.Maybe_bound.t ->
?max:float Core.Maybe_bound.t ->
t Core.Validate.check @@ portableval to_string : t -> string @@ portableComputes numerator / denominator when denominator is nonzero, otherwise returns else_. This is done without allocating or branching by unboxing the arguments and then using Unboxed.select.
module Infix : sig ... endThe result of arithmetic operations will be none if either operand is. In addition, if the float operation would give nan, the result is none.
module Ieee_nan : sig ... endOperations where we use NaN semantics even though they are inconsistent with the remaining operators, e.g., >= violates the equivalance a >= b <-> a > b || a = b because it returns false for two none inputs.
module Local : sig ... endmodule Stable : sig ... endmodule Unboxed : sig ... endA variant of the above type using unboxed floats. The operations are largely the same (but we can't currently share the module type across layouts.)
Returns true if both operands are none or (not none and equal).
module Ref : sig ... endFor records not consisting purely of floats, fields of t are preferable to mutable fields of Packed_float_option.t because their value can be mutated without crossing the GC write barrier.
module Without_infix : sig ... endPacked_float_option.t is the moral equivalent of float option represented under the hood as a regular float where Packed_float_option.is_none = Float.is_nan.
module type Unboxed_ref = sig ... end