Module Core_kernel.Float
Floating-point numbers.
include module type of sig ... end
val t_sexp_grammar : Base.Sexp.Private.Raw_grammar.tval of_float : float -> tval to_float : t -> floatval hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_valueval t_of_sexp : Sexplib0.Sexp.t -> tval sexp_of_t : t -> Sexplib0.Sexp.tval of_string : string -> tval (>=) : t -> t -> boolval (<=) : t -> t -> boolval (=) : t -> t -> boolval (>) : t -> t -> boolval (<) : t -> t -> boolval (<>) : t -> t -> boolval equal : t -> t -> boolval compare : t -> t -> intval min : t -> t -> tval max : t -> t -> tval ascending : t -> t -> intval descending : t -> t -> intval between : t -> low:t -> high:t -> boolval clamp_exn : t -> min:t -> max:t -> tval clamp : t -> min:t -> max:t -> t Base.Or_error.t
type comparator_witness= Base__Float.comparator_witness
val comparator : (t, comparator_witness) Base.Comparator.comparatorval validate_lbound : min:t Base.Maybe_bound.t -> t Base.Validate.checkval validate_ubound : max:t Base.Maybe_bound.t -> t Base.Validate.checkval validate_bound : min:t Base.Maybe_bound.t -> max:t Base.Maybe_bound.t -> t Base.Validate.checkval pp : Base.Formatter.t -> t -> unitval validate_positive : t Base.Validate.checkval validate_non_negative : t Base.Validate.checkval validate_negative : t Base.Validate.checkval validate_non_positive : t Base.Validate.checkval is_positive : t -> boolval is_non_negative : t -> boolval is_negative : t -> boolval is_non_positive : t -> boolval invariant : t Base__.Invariant_intf.invval validate_ordinary : t Base.Validate.checkval nan : tval infinity : tval neg_infinity : tval max_value : tval min_value : tval zero : tval one : tval minus_one : tval pi : tval sqrt_pi : tval sqrt_2pi : tval euler : tval epsilon_float : tval max_finite_value : tval min_positive_subnormal_value : tval min_positive_normal_value : tval to_int64_preserve_order : t -> int64 optionval to_int64_preserve_order_exn : t -> int64val of_int64_preserve_order : int64 -> tval one_ulp : [ `Down | `Up ] -> t -> tval of_int : int -> tval to_int : t -> intval of_int63 : Base.Int63.t -> tval of_int64 : int64 -> tval to_int64 : t -> int64val round : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> t -> tval iround : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> t -> int optionval iround_exn : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> t -> intval round_towards_zero : t -> tval round_down : t -> tval round_up : t -> tval round_nearest : t -> tval round_nearest_half_to_even : t -> tval iround_towards_zero : t -> int optionval iround_down : t -> int optionval iround_up : t -> int optionval iround_nearest : t -> int optionval iround_towards_zero_exn : t -> intval iround_down_exn : t -> intval iround_up_exn : t -> intval iround_nearest_exn : t -> intval int63_round_down_exn : t -> Base.Int63.tval int63_round_up_exn : t -> Base.Int63.tval int63_round_nearest_exn : t -> Base.Int63.tval iround_lbound : tval iround_ubound : tval round_significant : float -> significant_digits:int -> floatval round_decimal : float -> decimal_digits:int -> floatval is_nan : t -> boolval is_inf : t -> boolval min_inan : t -> t -> tval max_inan : t -> t -> tval (+) : t -> t -> tval (-) : t -> t -> tval (/) : t -> t -> tval (*) : t -> t -> tval (**) : t -> t -> tval (~-) : t -> t
module Parts = Base__Float.Partsval modf : t -> Parts.tval mod_float : t -> t -> tval add : t -> t -> tval sub : t -> t -> tval neg : t -> tval scale : t -> t -> tval abs : t -> t
module O = Base__Float.Omodule O_dot = Base__Float.O_dotval to_string : t -> stringval to_string_hum : ?delimiter:char -> ?decimals:int -> ?strip_zero:bool -> t -> stringval to_padded_compact_string : t -> stringval to_padded_compact_string_custom : t -> ?prefix:string -> kilo:string -> mega:string -> giga:string -> tera:string -> ?peta:string -> unit -> stringval int_pow : t -> int -> tval square : t -> tval ldexp : t -> int -> tval frexp : t -> t * int
val log10 : t -> tval expm1 : t -> tval log1p : t -> tval copysign : t -> t -> tval cos : t -> tval sin : t -> tval tan : t -> tval acos : t -> tval asin : t -> tval atan : t -> tval atan2 : t -> t -> tval hypot : t -> t -> tval cosh : t -> tval sinh : t -> tval tanh : t -> tval sqrt : t -> tval exp : t -> tval log : t -> t
module Class = Base__Float.Classval classify : t -> Class.tval is_finite : t -> boolval sign : t -> Base.Sign.tval sign_exn : t -> Base.Sign.tval sign_or_nan : t -> Base.Sign_or_nan.tval create_ieee : negative:bool -> exponent:int -> mantissa:Base.Int63.t -> t Base.Or_error.tval create_ieee_exn : negative:bool -> exponent:int -> mantissa:Base.Int63.t -> tval ieee_negative : t -> boolval ieee_exponent : t -> intval ieee_mantissa : t -> Base.Int63.t
module Terse = Base__Float.Tersemodule Private = Base__Float.Privatetype t= Core_kernel__.Import.float
include Typerep_lib.Typerepable.S with type t := t
val typerep_of_t : t Typerep_lib.Std_internal.Typerep.tval typename_of_t : t Typerep_lib.Typename.t
module Robust_compare : sig ... endThe results of robust comparisons on nan should be considered undefined.
include Robust_compare.S
val robust_comparison_tolerance : Core_kernel__.Import.floatintended to be a tolerance on human-entered floats
module O : sig ... endmodule Robustly_comparable : Robust_compare.Smodule Terse : sig ... endinclude Identifiable.S with type t := t and type comparator_witness := Base.Float.comparator_witness
include Bin_prot.Binable.S with type t := t
include Bin_prot.Binable.S_only_functions with type t := t
val bin_size_t : t Bin_prot.Size.sizerval bin_write_t : t Bin_prot.Write.writerval bin_read_t : t Bin_prot.Read.readerval __bin_read_t__ : (int -> t) Bin_prot.Read.readerThis function only needs implementation if
texposed 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 varianttafterwards.
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.t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_value
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
val t_of_sexp : Sexplib0.Sexp.t -> tval sexp_of_t : t -> Sexplib0.Sexp.t
include Identifiable.S_common with type t := t
val compare : t -> t -> Core_kernel__.Import.intval hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_valueval sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
include Core_kernel__.Import.Stringable.S with type t := t
include Core_kernel__.Import.Pretty_printer.S with type t := t
val pp : Base.Formatter.t -> t -> unit
include Comparable.S_binable 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 -> intascendingis identical tocompare.descending x y = ascending y x. These are intended to be mnemonic when used likeList.sort ~compare:ascendingandList.sort ~cmp:descending, since they cause the list to be sorted in ascending or descending order, respectively.
val descending : t -> t -> intval between : t -> low:t -> high:t -> boolbetween t ~low ~highmeanslow <= t <= high
val clamp_exn : t -> min:t -> max:t -> tclamp_exn t ~min ~maxreturnst', the closest value totsuch thatbetween t' ~low:min ~high:maxis 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.checkval validate_ubound : max:t Base.Maybe_bound.t -> t Base.Validate.checkval 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 := tinclude Core_kernel__.Comparable_intf.Map_and_set_binable with type t := t with type comparator_witness := comparator_witness
include Comparator.S with type t := t
val comparator : (t, comparator_witness) Comparator.comparator
module 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_witnessinclude Hashable.S_binable with type t := t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_value
val hashable : t Hashtbl.Hashable.t
module Table : Hashtbl.S_binable with type key = tmodule Hash_set : Hash_set.S_binable with type elt = tmodule Hash_queue : Hash_queue.S with type key = tval to_string_12 : t -> Core_kernel__.Import.stringto_string_12 xbuilds a string representingxusing up to 12 significant digits. It loses precision. You can use"%{Float#12}"in formats, but consider"%.12g","%{Float#hum}", or"%{Float}"as alternatives.
val to_string : t -> Core_kernel__.Import.stringto_string xbuilds a stringsrepresenting the floatxthat guarantees the round trip, i.e.,Float.equal x (Float.of_string s).It usually yields as few significant digits as possible. That is, it won't print
3.14as3.1400000000000001243. The only exception is that occasionally it will output 17 significant digits when the number can be represented with just 16 (but not 15 or fewer) of them.
include Quickcheckable.S with type t := t
val quickcheck_generator : t Base_quickcheck.Generator.tval quickcheck_observer : t Base_quickcheck.Observer.tval quickcheck_shrinker : t Base_quickcheck.Shrinker.t
val sign : t -> Sign.tval robust_sign : t -> Sign.t(Formerly
sign) Uses robust comparison (so sufficiently small numbers are mapped toZero). Also maps NaN toZero. Using this function is weakly discouraged.
val gen_uniform_excl : t -> t -> t Quickcheck.Generator.tgen_uniform_excl lo hicreates a Quickcheck generator producing finitetvalues betweenloandhi, exclusive. The generator approximates a uniform distribution over the interval (lo, hi). Raises an exception iflois not finite,hiis not finite, or the requested range is empty.The implementation chooses values uniformly distributed between 0 (inclusive) and 1 (exclusive) up to 52 bits of precision, then scales that interval to the requested range. Due to rounding errors and non-uniform floating point precision, the resulting distribution may not be precisely uniform and may not include all values between
loandhi.
val gen_incl : t -> t -> t Quickcheck.Generator.tgen_incl lo hicreates a Quickcheck generator that produces values betweenloandhi, inclusive, approximately uniformly distributed, with extra weight given to generating the endpointsloandhi. Raises an exception iflois not finite,hiis not finite, or the requested range is empty.
val gen_finite : t Quickcheck.Generator.tgen_finiteproduces all finitetvalues, excluding infinities and all NaN values.
val gen_positive : t Quickcheck.Generator.tgen_positiveproduces all (strictly) positive finitetvalues.
val gen_negative : t Quickcheck.Generator.tgen_negativeproduces all (strictly) negative finitetvalues.
val gen_without_nan : t Quickcheck.Generator.tgen_without_nanproduces all finite and infinitetvalues, excluding all NaN values.
val gen_infinite : t Quickcheck.Generator.tgen_infiniteproduces both infinite values
val gen_nan : t Quickcheck.Generator.tgen_nanproduces all NaN values.
val gen_normal : t Quickcheck.Generator.tgen_normalproduces all normal values
val gen_subnormal : t Quickcheck.Generator.tgen_subnormalproduces all subnormal values
val gen_zero : t Quickcheck.Generator.tgen_zeroproduces both zero values