package core_extended

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of struct include Core.Float end
type t = Base.Float.t
include sig ... end
val typerep_of_t : t Typerep_lib.Std.Typerep.t
val typename_of_t : t Typerep_lib.Std.Typename.t
module Robust_compare = Core.Float.Robust_compare

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 Core_kernel.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 = Core.Float.O
module Terse = Core.Float.Terse
include Core_kernel.Identifiable.S with type t := t and type comparator_witness := Base.Float.comparator_witness
include sig ... end
val bin_t : t Bin_prot.Type_class.t
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (Base.Int.t -> t) Bin_prot.Read.reader
val bin_reader_t : t Bin_prot.Type_class.reader
val bin_size_t : t Bin_prot.Size.sizer
val bin_write_t : t Bin_prot.Write.writer
val bin_writer_t : t Bin_prot.Type_class.writer
val bin_shape_t : Bin_prot.Shape.t
include Core_kernel.Identifiable.S_common with type t := t
include sig ... end
include Core_kernel.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
module Replace_polymorphic_compare = Core.Float.Replace_polymorphic_compare
include Core_kernel.Comparator.S with type t := t with type comparator_witness := Base.Float.comparator_witness
module Map = Core.Float.Map
module Set = Core.Float.Set
include Core_kernel.Hashable.S_binable with type t := t
include sig ... end
val hashable : t Core_kernel__.Hashtbl.Hashable.t
module Table = Core.Float.Table
module Hash_set = Core.Float.Hash_set
module Hash_queue = Core.Float.Hash_queue
include module type of struct include Base.Float end with type t := t with module O := Base.Float.O with module Terse := Base.Float.Terse
val of_float : float -> t
val to_float : t -> float
val hash_fold_t : Base__.Ppx_hash_lib.Std.Hash.state -> t -> Base__.Ppx_hash_lib.Std.Hash.state
val hash : t -> Base__.Ppx_hash_lib.Std.Hash.hash_value
val t_of_sexp : Base__.Ppx_sexp_conv_lib.Sexp.t -> t
val sexp_of_t : t -> Base__.Ppx_sexp_conv_lib.Sexp.t
val of_string : string -> t
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
type comparator_witness = Base__Float.comparator_witness
val comparator : (t, comparator_witness) Base__.Comparator.comparator
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
val pp : Base__.Formatter.t -> t -> unit
val validate_positive : t Base__.Validate.check
val validate_non_negative : t Base__.Validate.check
val validate_negative : t Base__.Validate.check
val validate_non_positive : t Base__.Validate.check
val is_positive : t -> bool
val is_non_negative : t -> bool
val is_negative : t -> bool
val is_non_positive : t -> bool
val validate_ordinary : t Base__.Validate.check
val nan : t
val infinity : t
val neg_infinity : t
val max_value : t
val min_value : t
val zero : t
val one : t
val minus_one : t
val pi : t
val sqrt_pi : t
val sqrt_2pi : t
val euler : t
val epsilon_float : t
val max_finite_value : t
val min_positive_subnormal_value : t
val min_positive_normal_value : t
val to_int64_preserve_order : t -> int64 option
val to_int64_preserve_order_exn : t -> int64
val of_int64_preserve_order : int64 -> t
val one_ulp : [ `Down | `Up ] -> t -> t
val of_int : int -> t
val to_int : t -> int
val of_int63 : Base__.Int63.t -> t
val of_int64 : int64 -> t
val to_int64 : t -> int64
val round : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> t -> t
val iround : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> t -> int option
val iround_exn : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> t -> int
val round_towards_zero : t -> t
val round_down : t -> t
val round_up : t -> t
val round_nearest : t -> t
val round_nearest_half_to_even : t -> t
val iround_towards_zero : t -> int option
val iround_down : t -> int option
val iround_up : t -> int option
val iround_nearest : t -> int option
val iround_towards_zero_exn : t -> int
val iround_down_exn : t -> int
val iround_up_exn : t -> int
val iround_nearest_exn : t -> int
val int63_round_down_exn : t -> Base__.Int63.t
val int63_round_up_exn : t -> Base__.Int63.t
val int63_round_nearest_exn : t -> Base__.Int63.t
val iround_lbound : t
val iround_ubound : t
val round_significant : float -> significant_digits:int -> float
val round_decimal : float -> decimal_digits:int -> float
val is_nan : t -> bool
val is_inf : t -> bool
val min_inan : t -> t -> t
val max_inan : t -> t -> t
val (+) : t -> t -> t
val (-) : t -> t -> t
val (/) : t -> t -> t
val (*) : t -> t -> t
val (**) : t -> t -> t
val (~-) : t -> t
module Parts = Core.Float.Parts
val modf : t -> Parts.t
val mod_float : t -> t -> t
val add : t -> t -> t
val sub : t -> t -> t
val neg : t -> t
val scale : t -> t -> t
val abs : t -> t
module O_dot = Core.Float.O_dot
val to_padded_compact_string : t -> string
val int_pow : t -> int -> t
val ldexp : t -> int -> t
val frexp : t -> t * int
val log10 : t -> t
val expm1 : t -> t
val log1p : t -> t
val copysign : t -> t -> t
val cos : t -> t
val sin : t -> t
val tan : t -> t
val acos : t -> t
val asin : t -> t
val atan : t -> t
val atan2 : t -> t -> t
val hypot : t -> t -> t
val cosh : t -> t
val sinh : t -> t
val tanh : t -> t
val sqrt : t -> t
val exp : t -> t
val log : t -> t
module Class = Core.Float.Class
val classify : t -> Class.t
val is_finite : t -> bool
val sign_exn : t -> Base__.Sign.t
module Sign_or_nan = Core.Float.Sign_or_nan
val sign_or_nan : t -> Sign_or_nan.t
val create_ieee : negative:bool -> exponent:int -> mantissa:Base__.Int63.t -> t Base__.Or_error.t
val create_ieee_exn : negative:bool -> exponent:int -> mantissa:Base__.Int63.t -> t
val ieee_negative : t -> bool
val ieee_exponent : t -> int
val ieee_mantissa : t -> Base__.Int63.t
module Private = Core.Float.Private
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.

val to_string_round_trippable : t -> Base.String.t
  • deprecated [since 2017-04] Use [Float.to_string]
val sign : t -> Core_kernel.Sign.t
  • deprecated [since 2016-01] Replace [sign] with [robust_sign] or [sign_exn]
val robust_sign : t -> Core_kernel.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 Core_kernel.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.

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.

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

gen_positive produces all (strictly) positive finite t values.

gen_negative produces all (strictly) negative finite t values.

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

include module type of struct include Extended_float end
val pretty : ?on_negative:[ `Blow_up | `Normal | `Print_dir ] -> float -> string

pretty-print a float using no more than five characters, using abberviations k, m, g, t.

if on_negative is not set to `Normal then the resulting is never over four chars but upon negative number we either:

  • raise a failure
  • or print "<0"
val to_string_hum : float -> string
val order_of_magnitude_difference : float -> float -> int

order_of_magnitude_difference a b by how many orders of magnitude do a and b differ? The return value is non-negative.

examples:

  • order_of_magnitude_difference 11. 1001. = 2
  • order_of_magnitude_difference 1001. 11. = 2
  • order_of_magnitude_difference 131. 11. = 1
  • order_of_magnitude_difference 200. 0.003 = 5
include Number.Verified_std with type repr = Core.Float.t
type repr = Core.Float.t
module type S = Extended_float.S

Abbreviations

module type S0 = Extended_float.S0
module Pos = Extended_float.Pos

Positive and negative numbers with and without zero.

module Pos0 = Extended_float.Pos0
module Neg = Extended_float.Neg
module Neg0 = Extended_float.Neg0
module type Bounded_spec = Extended_float.Bounded_spec

Specification of bounded numbers

module type Bounded = Extended_float.Bounded

Signature of bounded numbers

module Make_bounded = Extended_float.Make_bounded

Functor of creating bounded numbers

Unsafe modules and functors that still fully expose the representation for extensibility.

module Pos_unsafe = Extended_float.Pos_unsafe
module Pos0_unsafe = Extended_float.Pos0_unsafe
module Neg_unsafe = Extended_float.Neg_unsafe
module Neg0_unsafe = Extended_float.Neg0_unsafe
module Make_bounded_unsafe = Extended_float.Make_bounded_unsafe
module type Fraction = Extended_float.Fraction
module Fraction = Extended_float.Fraction
module Fraction_unsafe = Extended_float.Fraction_unsafe
OCaml

Innovation. Community. Security.