package core

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Floating-point numbers.

val globalize : float -> float
val t_sexp_grammar : float Sexplib0.Sexp_grammar.t
val of_float : float -> float
val to_float : float -> float
type comparator_witness = Base__Float.comparator_witness
val of_string_opt : string -> float option
val is_positive : float -> bool
val is_non_negative : float -> bool
val is_negative : float -> bool
val is_non_positive : float -> bool
val invariant : float Base__Invariant_intf.inv
val nan : float
val infinity : float
val neg_infinity : float
val max_value : float
val min_value : float
val zero : float
val one : float
val minus_one : float
val pi : float
val sqrt_pi : float
val sqrt_2pi : float
val euler : float
val epsilon_float : float
val max_finite_value : float
val min_positive_subnormal_value : float
val min_positive_normal_value : float
val to_int64_preserve_order : float -> int64 option
val to_int64_preserve_order_exn : float -> int64
val of_int64_preserve_order : int64 -> float
val one_ulp : [ `Down | `Up ] -> float -> float
val of_int : int -> float
val to_int : float -> int
val of_int63 : Base__.Int63.t -> float
val of_int64 : int64 -> float
val to_int64 : float -> int64
val round : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> float -> float
val iround : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> float -> int option
val iround_exn : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> float -> int
val round_towards_zero : float -> float
val round_down : float -> float
val round_up : float -> float
val round_nearest : float -> float
val round_nearest_half_to_even : float -> float
val iround_towards_zero : float -> int option
val iround_down : float -> int option
val iround_up : float -> int option
val iround_nearest : float -> int option
val iround_towards_zero_exn : float -> int
val iround_down_exn : float -> int
val iround_up_exn : float -> int
val iround_nearest_exn : float -> int
val int63_round_down_exn : float -> Base__.Int63.t
val int63_round_up_exn : float -> Base__.Int63.t
val int63_round_nearest_exn : float -> Base__.Int63.t
val iround_lbound : float
val iround_ubound : float
val int63_round_lbound : float
val int63_round_ubound : float
val round_significant : float -> significant_digits:int -> float
val round_decimal : float -> decimal_digits:int -> float
val is_nan : float -> bool
val is_inf : float -> bool
val is_finite : float -> bool
val is_integer : float -> bool
val min_inan : float -> float -> float
val max_inan : float -> float -> float
val (+) : float -> float -> float
val (-) : float -> float -> float
val (/) : float -> float -> float
val (%) : float -> float -> float
val (*) : float -> float -> float
val (**) : float -> float -> float
val (~-) : float -> float
module Parts : sig ... end
val modf : float -> Parts.t
val mod_float : float -> float -> float
val add : float -> float -> float
val sub : float -> float -> float
val neg : float -> float
val scale : float -> float -> float
val abs : float -> float
module O_dot : sig ... end
val to_string_hum : ?delimiter:char -> ?decimals:int -> ?strip_zero:bool -> ?explicit_plus:bool -> float -> string
val to_padded_compact_string : float -> string
val to_padded_compact_string_custom : float -> ?prefix:string -> kilo:string -> mega:string -> giga:string -> tera:string -> ?peta:string -> unit -> string
val int_pow : float -> int -> float
val square : float -> float
val ldexp : float -> int -> float
val frexp : float -> float * int
val log10 : float -> float
val expm1 : float -> float
val log1p : float -> float
val copysign : float -> float -> float
val cos : float -> float
val sin : float -> float
val tan : float -> float
val acos : float -> float
val asin : float -> float
val atan : float -> float
val atan2 : float -> float -> float
val hypot : float -> float -> float
val cosh : float -> float
val sinh : float -> float
val tanh : float -> float
val acosh : float -> float
val asinh : float -> float
val atanh : float -> float
val sqrt : float -> float
val exp : float -> float
val log : float -> float
module Class : sig ... end
val classify : float -> Class.t
val sign_exn : float -> Base__.Sign.t
val sign_or_nan : float -> Base__.Sign_or_nan.t
val create_ieee : negative:bool -> exponent:int -> mantissa:Base__.Int63.t -> float Base__.Or_error.t
val create_ieee_exn : negative:bool -> exponent:int -> mantissa:Base__.Int63.t -> float
val ieee_negative : float -> bool
val ieee_exponent : float -> int
val ieee_mantissa : float -> Base__.Int63.t
module Private : sig ... end
type t = Base.Float.t
include Typerep_lib.Typerepable.S with type t := t
val typerep_of_t : t Typerep_lib.Std_internal.Typerep.t
val typename_of_t : t Typerep_lib.Typename.t
module Robust_compare : sig ... end

So-called "robust" comparisons, which include a small tolerance, so that float that differ by a small amount are considered equal.

Note that the results of robust comparisons on nan should be considered undefined.

include Robust_compare.S
val robust_comparison_tolerance : Base.Float.t

intended to be a tolerance on human-entered floats

include Robustly_comparable.S with type t := Base.Float.t
val (>=.) : Base.Float.t -> Base.Float.t -> bool
val (<=.) : Base.Float.t -> Base.Float.t -> bool
val (=.) : Base.Float.t -> Base.Float.t -> bool
val (>.) : Base.Float.t -> Base.Float.t -> bool
val (<.) : Base.Float.t -> Base.Float.t -> bool
val (<>.) : Base.Float.t -> Base.Float.t -> bool
val robustly_compare : Base.Float.t -> Base.Float.t -> int
module O : sig ... end
module Terse : sig ... end
include Identifiable.S with type t := t and type comparator_witness := Base.Float.comparator_witness
include Bin_prot.Binable.S with type t := t
val bin_size_t : t Bin_prot__.Size.sizer
val bin_write_t : t Bin_prot__.Write.writer
val bin_read_t : t Bin_prot__.Read.reader
val __bin_read_t__ : (int -> t) Bin_prot__.Read.reader
val bin_shape_t : Bin_prot__.Shape.t
val bin_writer_t : t Bin_prot__.Type_class.writer
val bin_reader_t : t Bin_prot__.Type_class.reader
val bin_t : t Bin_prot__.Type_class.t
include Ppx_hash_lib.Hashable.S with type t := t
include Sexplib0.Sexpable.S with type t := t
val t_of_sexp : Sexplib0__.Sexp.t -> t
include Ppx_compare_lib.Comparable.S with type t := t
include Ppx_hash_lib.Hashable.S with type t := t
val sexp_of_t : t -> Sexplib0.Sexp.t
val of_string : string -> t
val pp : Base__.Formatter.t -> t -> unit
include Comparable.S_binable with type t := t with type comparator_witness := Base.Float.comparator_witness
include Base.Comparable.S with type t := t with type comparator_witness := Base.Float.comparator_witness
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (=) : t -> t -> bool
val (>) : t -> t -> bool
val (<) : t -> t -> bool
val (<>) : t -> t -> bool
val equal : t -> t -> bool
val compare : t -> t -> int
val min : t -> t -> t
val max : t -> t -> t
val ascending : t -> t -> int
val descending : t -> t -> int
val between : t -> low:t -> high:t -> bool
val clamp_exn : t -> min:t -> max:t -> t
val clamp : t -> min:t -> max:t -> t Base__.Or_error.t
module Replace_polymorphic_compare : sig ... end
include Comparator.S with type t := t with type comparator_witness := Base.Float.comparator_witness
val comparator : (t, Base.Float.comparator_witness) Comparator.comparator
module Map : Map.S_binable with type Key.t = t with type Key.comparator_witness = Base.Float.comparator_witness
module Set : Set.S_binable with type Elt.t = t with type Elt.comparator_witness = Base.Float.comparator_witness
include Hashable.S_binable with type t := t
include Ppx_hash_lib.Hashable.S with type t := t
val hash_fold_t : t Base__Ppx_hash_lib.hash_fold
val hash : t -> Base__Ppx_hash_lib.Std.Hash.hash_value
val hashable : t Core__.Hashtbl.Hashable.t
module Table : Hashtbl.S_binable with type key = t
module Hash_set : Hash_set.S_binable with type elt = t
module Hash_queue : Hash_queue.S with type key = t
include Comparable.Validate_with_zero with type t := t
val validate_lbound : min:t Maybe_bound.t -> t Validate.check
val validate_ubound : max:t Maybe_bound.t -> t Validate.check
val validate_bound : min:t Maybe_bound.t -> max:t Maybe_bound.t -> t Validate.check
val validate_positive : t Validate.check
val validate_non_negative : t Validate.check
val validate_negative : t Validate.check
val validate_non_positive : t Validate.check
val validate_ordinary : t Validate.check

validate_ordinary fails if class is Nan or Infinite.

val to_string_12 : t -> Base.String.t

to_string_12 x builds a string representing x using 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 -> Base.String.t

to_string x builds a string s representing the float x that 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.14 as 3.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.t
val quickcheck_observer : t Base_quickcheck.Observer.t
val quickcheck_shrinker : t Base_quickcheck.Shrinker.t
val sign : t -> Sign.t
  • deprecated [since 2016-01] Replace [sign] with [robust_sign] or [sign_exn]
val robust_sign : t -> Sign.t

(Formerly sign) Uses robust comparison (so sufficiently small numbers are mapped to Zero). Also maps NaN to Zero. Using this function is weakly discouraged.

val gen_uniform_excl : t -> t -> t Quickcheck.Generator.t

gen_uniform_excl lo hi creates a Quickcheck generator producing finite t values between lo and hi, exclusive. The generator approximates a uniform distribution over the interval (lo, hi). Raises an exception if lo is not finite, hi is 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 lo and hi.

val gen_incl : t -> t -> t Quickcheck.Generator.t

gen_incl lo hi creates a Quickcheck generator that produces values between lo and hi, inclusive, approximately uniformly distributed, with extra weight given to generating the endpoints lo and hi. Raises an exception if lo is not finite, hi is not finite, or the requested range is empty.

val gen_finite : t Quickcheck.Generator.t

gen_finite produces all finite t values, excluding infinities and all NaN values.

val gen_positive : t Quickcheck.Generator.t

gen_positive produces all (strictly) positive finite t values.

val gen_negative : t Quickcheck.Generator.t

gen_negative produces all (strictly) negative finite t values.

val gen_without_nan : t Quickcheck.Generator.t

gen_without_nan produces all finite and infinite t values, excluding all NaN values.

val gen_infinite : t Quickcheck.Generator.t

gen_infinite produces both infinite values

gen_nan produces all NaN values.

val gen_normal : t Quickcheck.Generator.t

gen_normal produces all normal values

val gen_subnormal : t Quickcheck.Generator.t

gen_subnormal produces all subnormal values

val gen_zero : t Quickcheck.Generator.t

gen_zero produces both zero values

module Stable : sig ... end

Note that float is already stable by itself, since as a primitive type it is an integral part of the sexp / bin_io protocol. Float.Stable exists only to introduce Float.Stable.Set and Float.Stable.Map, and provide interface uniformity with other stable types.

OCaml

Innovation. Community. Security.